From: John Marino Date: Thu, 7 Apr 2011 06:28:22 +0000 (+0200) Subject: binutils221: revisit start/stop label generation X-Git-Tag: v2.11.0~82 X-Git-Url: https://gitweb.dragonflybsd.org/dragonfly.git/commitdiff_plain/f070647cc5317c4924be4dd60563fc39c18094cf binutils221: revisit start/stop label generation In commit b133d3fde203bbf8e2c359d2be9f09c20ce732b5 (3 April), ld's lang_insert_orphan function was modified to include all symbols, which matches the behavior of binutils 2.17 and allowed kernel modules utilizing previously unreferenced __start_* and __stop_* sections to load properly. For at least 4 years, the ld developed by binutils has the policy to discard all unreference symbols, considering them "clutter". This commit will revert back ld back to its default behavior unless the options -shared or -Bshareable are passed in the command line. In those cases, the linked file will include all symbols, referenced or not. In the future, we may consider modifying an .em file to define a flag that will revert to 2.17 on a per-target basis rather than forcing all shared objects to carry extraneous symbols. I'd have to identify all kernel modules requiring this flag before implementing that change. --- diff --git a/contrib/binutils-2.21/README.DRAGONFLY b/contrib/binutils-2.21/README.DRAGONFLY index b839636550..6dfd95103e 100644 --- a/contrib/binutils-2.21/README.DRAGONFLY +++ b/contrib/binutils-2.21/README.DRAGONFLY @@ -39,4 +39,5 @@ bfd/config.bfd binutils/arlex.l gas/config/tc-i386.c + ld/ldlang.c ld/ldlex.l diff --git a/contrib/binutils-2.21/ld/ldlang.c b/contrib/binutils-2.21/ld/ldlang.c index 4d5d1995d3..a895521b84 100644 --- a/contrib/binutils-2.21/ld/ldlang.c +++ b/contrib/binutils-2.21/ld/ldlang.c @@ -1757,9 +1757,15 @@ lang_insert_orphan (asection *s, e_align = exp_unop (ALIGN_K, exp_intop ((bfd_vma) 1 << s->alignment_power)); lang_add_assignment (exp_assign (".", e_align)); - lang_add_assignment (exp_assign (symname, - exp_unop (ABSOLUTE, - exp_nameop (NAME, ".")))); + if (link_info.shared) + lang_add_assignment (exp_assign (symname, + exp_unop (ABSOLUTE, + exp_nameop (NAME, ".")))); + else + lang_add_assignment (exp_provide (symname, + exp_unop (ABSOLUTE, + exp_nameop (NAME, ".")), + FALSE)); } } @@ -1789,8 +1795,13 @@ lang_insert_orphan (asection *s, symname = (char *) xmalloc (ps - secname + sizeof "__stop_" + 1); symname[0] = bfd_get_symbol_leading_char (link_info.output_bfd); sprintf (symname + (symname[0] != 0), "__stop_%s", secname); - lang_add_assignment (exp_assign (symname, - exp_nameop (NAME, "."))); + if (link_info.shared) + lang_add_assignment (exp_assign (symname, + exp_nameop (NAME, "."))); + else + lang_add_assignment (exp_provide (symname, + exp_nameop (NAME, "."), + FALSE)); } /* Restore the global list pointer. */