]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Revert "Strip undefined symbols from .symtab"
authorAlan Modra <amodra@gmail.com>
Thu, 14 Jan 2016 08:32:18 +0000 (19:02 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 14 Jan 2016 10:12:03 +0000 (20:42 +1030)
This reverts commit d983c8c5503d680c6d4955ceb610a9beebc64460 and
db95bb7c5946a109e1584ab2c43c052ff39e63bd

The PR4317 patch introduced a ppc64le linux kernel build problem.

PR ld/19421
PR ld/4317
bfd/
* elflink.c (elf_link_input_bfd): Revert 2015-02-19 changes.
(elf_link_output_extsym): Likewise.
ld/
* ld-aarch64/gc-tls-relocs.d: Revert 2015-02-19 changes.
* ld-cris/locref2.d: Likewise.
* ld-elf/ehdr_start-weak.d: Likewise.
* ld-elf/group1.d: Likewise.
* ld-i386/compressed1.d: Likewise.
* ld-ia64/error1.d: Likewise.
* ld-ia64/error2.d: Likewise.
* ld-ia64/error3.d: Likewise.
* ld-mips-elf/pic-and-nonpic-1.nd: Likewise.
* ld-mmix/undef-3.d: Likewise.
* ld-powerpc/tlsexe.r: Likewise.
* ld-powerpc/tlsexetoc.r: Likewise.
* ld-powerpc/tlsso.r: Likewise.
* ld-powerpc/tlstocso.r: Likewise.
* ld-x86-64/compressed1.d: Likewise.
* ld-x86-64/pie1.d: Likewise.

19 files changed:
bfd/ChangeLog
bfd/elflink.c
ld/testsuite/ChangeLog
ld/testsuite/ld-aarch64/gc-tls-relocs.d
ld/testsuite/ld-cris/locref2.d
ld/testsuite/ld-elf/ehdr_start-weak.d
ld/testsuite/ld-elf/group1.d
ld/testsuite/ld-i386/compressed1.d
ld/testsuite/ld-ia64/error1.d
ld/testsuite/ld-ia64/error2.d
ld/testsuite/ld-ia64/error3.d
ld/testsuite/ld-mips-elf/pic-and-nonpic-1.nd
ld/testsuite/ld-mmix/undef-3.d
ld/testsuite/ld-powerpc/tlsexe.r
ld/testsuite/ld-powerpc/tlsexetoc.r
ld/testsuite/ld-powerpc/tlsso.r
ld/testsuite/ld-powerpc/tlstocso.r
ld/testsuite/ld-x86-64/compressed1.d
ld/testsuite/ld-x86-64/pie1.d

index d28df51a3ecb106a1a5cb3dac0dd76ac8c8f1066..842b913df9ad528c99ad766e3efddce297fb06e8 100644 (file)
@@ -1,3 +1,10 @@
+2016-01-14  Alan Modra  <amodra@gmail.com>
+
+       PR ld/19421
+       PR ld/4317
+       * elflink.c (elf_link_input_bfd): Revert 2015-02-19 changes.
+       (elf_link_output_extsym): Likewise.
+
 2016-01-11  Jiong Wang  <jiong.wang@arm.com>
 
        Apply from master
index 1b41c793a978dd5d974c8e73927a5b8d85416b33..3d37bb422537ab428113bf5cfb87ba6bbae42761 100644 (file)
@@ -9145,9 +9145,8 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
      a regular file, or that we have been told to strip.  However, if
      h->indx is set to -2, the symbol is used by a reloc and we must
      output it.  */
-  strip = FALSE;
   if (h->indx == -2)
-    ;
+    strip = FALSE;
   else if ((h->def_dynamic
            || h->ref_dynamic
            || h->root.type == bfd_link_hash_new)
@@ -9173,11 +9172,12 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
           && h->root.u.undef.abfd != NULL
           && (h->root.u.undef.abfd->flags & BFD_PLUGIN) != 0)
     strip = TRUE;
+  else
+    strip = FALSE;
 
   /* If we're stripping it, and it's not a dynamic symbol, there's
-     nothing else to do.   However, if it is a forced local symbol or
-     an ifunc symbol we need to give the backend finish_dynamic_symbol
-     function a chance to make it dynamic.  */
+     nothing else to do unless it is a forced local symbol or a
+     STT_GNU_IFUNC symbol.  */
   if (strip
       && h->dynindx == -1
       && h->type != STT_GNU_IFUNC
@@ -9457,18 +9457,9 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
        }
     }
 
-  /* If the symbol is undefined, and we didn't output it to .dynsym,
-     strip it from .symtab too.  Obviously we can't do this for
-     relocatable output or when needed for --emit-relocs.  */
-  else if (input_sec == bfd_und_section_ptr
-          && h->indx != -2
-          && !bfd_link_relocatable (flinfo->info))
-    return TRUE;
-  /* Also strip others that we couldn't earlier due to dynamic symbol
-     processing.  */
-  if (strip)
-    return TRUE;
-  if ((input_sec->flags & SEC_EXCLUDE) != 0)
+  /* If we're stripping it, then it was just a dynamic symbol, and
+     there's nothing else to do.  */
+  if (strip || (input_sec->flags & SEC_EXCLUDE) != 0)
     return TRUE;
 
   /* Output a FILE symbol so that following locals are not associated
@@ -9718,9 +9709,8 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
 
       *ppsection = isec;
 
-      /* Don't output the first, undefined, symbol.  In fact, don't
-        output any undefined local symbol.  */
-      if (isec == bfd_und_section_ptr)
+      /* Don't output the first, undefined, symbol.  */
+      if (ppsection == flinfo->sections)
        continue;
 
       if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
index 6784fe56805a4161a15d7258f00a77fb4f32ed54..14edc57a321d585fcc9909cf8db8cfcefcde6493 100644 (file)
@@ -1,3 +1,24 @@
+2016-01-14  Alan Modra  <amodra@gmail.com>
+
+       PR ld/19421
+       PR ld/4317
+       * ld-aarch64/gc-tls-relocs.d: Revert 2015-02-19 changes.
+       * ld-cris/locref2.d: Likewise.
+       * ld-elf/ehdr_start-weak.d: Likewise.
+       * ld-elf/group1.d: Likewise.
+       * ld-i386/compressed1.d: Likewise.
+       * ld-ia64/error1.d: Likewise.
+       * ld-ia64/error2.d: Likewise.
+       * ld-ia64/error3.d: Likewise.
+       * ld-mips-elf/pic-and-nonpic-1.nd: Likewise.
+       * ld-mmix/undef-3.d: Likewise.
+       * ld-powerpc/tlsexe.r: Likewise.
+       * ld-powerpc/tlsexetoc.r: Likewise.
+       * ld-powerpc/tlsso.r: Likewise.
+       * ld-powerpc/tlstocso.r: Likewise.
+       * ld-x86-64/compressed1.d: Likewise.
+       * ld-x86-64/pie1.d: Likewise.
+
 2016-01-13  Nick Clifton  <nickc@redhat.com>
 
        * ld-elf/elf.exp (-Bymsolic-functions): Expect to fail
index 480d869917ec6061ae466b75981c9afd37bb0cb9..191647ca3106a0f305c71411f48056a4dee947ab 100644 (file)
@@ -17,6 +17,7 @@ SYMBOL TABLE:
 0+9000 l    d  \.got   0+ \.got
 0+0000 l    df \*ABS\* 0+ .*
 0+0000 l    df \*ABS\* 0+ 
+0+0000 l       \*UND\* 0+ __tls_get_addr
 0+9000 l     O \.got   0+ _GLOBAL_OFFSET_TABLE_
 0+8000 g       \.text  0+ _start
 
index 0cf53946cb569a1ead161d78e0d3c36fd9f5ab3b..735b10ec4fffd9309f7d5adb4d6be9e67a0dc77c 100644 (file)
@@ -12,6 +12,8 @@
 SYMBOL TABLE:
 #...
 0+82088 l     O \.got  0+ _GLOBAL_OFFSET_TABLE_
+0+  w      \*UND\*     0+ expfn
+0+  w      \*UND\*     0+ expobj
 #...
 Disassembly of section \.text:
 #...
index 5644d0537dc23410dcc4d51e84a0b814a992d3fa..24ae34cda711f24a2c46ef5e8750b10620b609e0 100644 (file)
@@ -4,7 +4,6 @@
 #target: *-*-linux* *-*-gnu* *-*-nacl*
 #xfail: frv-*-*
 
-#failif
-#...
-.* __ehdr_start
 #...
+\s+[wU] __ehdr_start
+#pass
index 257be11fac4391ff0713bbcd547d835bedd4dbf2..ff675352675387fead13c6fcad2503c6be58c822 100644 (file)
@@ -8,3 +8,5 @@
 Symbol table '.symtab' contains .* entries:
 #...
 .*: 0+1000 +0 +(NOTYPE|OBJECT) +WEAK +DEFAULT +. foo
+.*: 0+0000 +0 +(NOTYPE|OBJECT) +GLOBAL +DEFAULT +UND bar
+#...
index e9eeef9ae2a5b8d2beed91031bbb753ebf41d768..3a57c815a9a7a9fec6f07eafdd1988bfd1890c9f 100644 (file)
@@ -4,7 +4,6 @@
 #warning: .*/compressed1.c:13: undefined reference to .bar.
 #nm: -n
 
-#failif
 #...
 [ \t]+U bar
-#...
+#pass
index 7b2476f95e5c67a1006cf2f49774e196a1b9ec52..82142b6a11e64125411caa2124de4e86672ac867 100644 (file)
@@ -2,4 +2,6 @@
 #ld: -unresolved-symbols=ignore-all
 #readelf: -s
 
+#...
+[      ]+[0-9]+:[      ]+[0]+[         ]+0[    ]+NOTYPE[       ]+GLOBAL DEFAULT[       ]+UND[  ]+foo
 #pass
index ae74eaa464b2767c3048364d75623baa1b2aff18..764ba66d279dae87ecf8783d00c5be3f04ef0696 100644 (file)
@@ -2,4 +2,6 @@
 #ld: -pie -unresolved-symbols=ignore-all
 #readelf: -s
 
+#...
+[      ]+[0-9]+:[      ]+[0]+[         ]+0[    ]+NOTYPE[       ]+GLOBAL DEFAULT[       ]+UND[  ]+foo
 #pass
index 256a6fdc17b783c50431b1f08273d4793df8b1d6..e14d451bbaef442214e7ec0fe78ff63555955178 100644 (file)
@@ -2,4 +2,6 @@
 #ld: -pie -shared
 #readelf: -s
 
+#...
+[      ]+[0-9]+:[      ]+[0]+[         ]+0[    ]+NOTYPE[       ]+GLOBAL DEFAULT[       ]+UND[  ]+foo
 #pass
index 3c449fbcb7ae17292b35ddb9ff50f3343da16c51..78a1c60579732dd69c1a4602ba60e66ba206513b 100644 (file)
@@ -2,6 +2,7 @@
 .*: 00068000 +0 +NOTYPE +LOCAL +DEFAULT +ABS _gp
 .*: 00041018 +8 +FUNC +LOCAL +DEFAULT .* .pic.f1
 .*: 00041000 +16 +FUNC +LOCAL +DEFAULT .* .pic.f2
+.*: 00000000 +0 +OBJECT +GLOBAL +DEFAULT +UND _gp_disp
 .*: 00041050 +14 +FUNC +GLOBAL +DEFAULT +\[MIPS16\] .* f3
 .*: 00041060 +24 +FUNC +GLOBAL +DEFAULT .* __start
 .*: 0004103c +20 +FUNC +GLOBAL +DEFAULT .* f2
index 94eeeaa5a7b775f833a898fedf1c54dc71e55672..51c0e729ffab70a89ef06a434528f141d70af7e7 100644 (file)
@@ -14,18 +14,19 @@ Section Headers:
  +\[ 2\] \.shstrtab +STRTAB +0+ +[0-9a-f]+
  +0+21 +0+ +0 +0 +1
  +\[ 3\] \.symtab +SYMTAB +0+ .*
- +0+a8 +0+18 +4 +2 +8
+ +0+c0 +0+18 +4 +2 +8
  +\[ 4\] \.strtab +STRTAB +0+ .*
- +0+21 +0+ +0 +0 +1
+ +0+28 +0+ +0 +0 +1
 Key to Flags:
 #...
 
-Symbol table '\.symtab' contains 7 entries:
+Symbol table '\.symtab' contains 8 entries:
  +Num: +Value +Size +Type +Bind +Vis +Ndx +Name
  +0: 0+ +0 +NOTYPE +LOCAL +DEFAULT +UND 
  +1: 0+ +0 +SECTION +LOCAL +DEFAULT +1 
- +2: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +1 _start
- +3: 2000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 __bss_start
- +4: 2000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 _edata
- +5: 2000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 _end
- +6: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +1 _start\.
+ +2: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND undefd
+ +3: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +1 _start
+ +4: 2000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 __bss_start
+ +5: 2000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 _edata
+ +6: 2000000000000000 +0 +NOTYPE +GLOBAL +DEFAULT +1 _end
+ +7: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +1 _start\.
index db72ad72866f2037711c8b118900ddc7312496c9..ab2ac870cdd27e4e9ed2457310ea0bcf15dcd440 100644 (file)
@@ -98,8 +98,9 @@ Symbol table '\.symtab' contains [0-9]+ entries:
 .* TLS +LOCAL +DEFAULT +8 le5
 .* FILE +LOCAL +DEFAULT +ABS 
 .* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC
-.* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve
-.* NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt)
+.* (NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve|(FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt))
+.* (NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt)|NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve)
+.* ((FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt)|NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt))
 .* GLOBAL +DEFAULT +UND gd
 .* GLOBAL +DEFAULT +9 le0
 .* GLOBAL +DEFAULT +9 ld0
index 56716bba8eb9afee1710daf47acbcf82e353b4fb..a72f80fe0e6a0649e4a73fb26afe6d0579e7056f 100644 (file)
@@ -98,8 +98,9 @@ Symbol table '\.symtab' contains [0-9]+ entries:
 .* NOTYPE +LOCAL +DEFAULT +12 \.Lie0
 .* FILE +LOCAL +DEFAULT +ABS 
 .* OBJECT +LOCAL +DEFAULT +10 _DYNAMIC
-.* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve
-.* NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt)
+.* (NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve|(FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt))
+.* (NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt)|NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve)
+.* ((FUNC|NOTYPE) +LOCAL +DEFAULT +UND \.__tls_get_addr(|_opt)|NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt))
 .* TLS +GLOBAL +DEFAULT +UND gd
 .* TLS +GLOBAL +DEFAULT +9 le0
 .* TLS +GLOBAL +DEFAULT +9 ld0
index fd3002bed185fc3417e61994d725ca70156a5df1..46b143a62111a1cec6f7cf252c4508690da75be3 100644 (file)
@@ -116,6 +116,7 @@ Symbol table '\.symtab' contains [0-9]+ entries:
 .* OBJECT +LOCAL +DEFAULT +9 _DYNAMIC
 .* NOTYPE +LOCAL +DEFAULT +6 .*\.plt_call\.__tls_get_addr
 .* NOTYPE +LOCAL +DEFAULT +6 __glink_PLTresolve
+.* NOTYPE +LOCAL +DEFAULT +UND \.__tls_get_addr
 .* TLS +GLOBAL +DEFAULT +UND gd
 .* TLS +GLOBAL +DEFAULT +8 le0
 .* NOTYPE +GLOBAL +DEFAULT +UND __tls_get_addr
index 765bf08f32f01517d394addbcb3b02433f4271e0..542e8d5aa0fb4e948e8a41e7d977d8dd2ebafd5f 100644 (file)
@@ -112,6 +112,7 @@ Symbol table '\.symtab' contains [0-9]+ entries:
 .* OBJECT +LOCAL +DEFAULT +9 _DYNAMIC
 .* NOTYPE +LOCAL +DEFAULT +6 .*\.plt_call\.__tls_get_addr
 .* NOTYPE +LOCAL +DEFAULT +6 __glink_PLTresolve
+.* NOTYPE +LOCAL +DEFAULT +UND \.__tls_get_addr
 .* TLS +GLOBAL +DEFAULT +UND gd
 .* TLS +GLOBAL +DEFAULT +8 le0
 .* NOTYPE +GLOBAL +DEFAULT +UND __tls_get_addr
index f97c9ad7da63d34fabedccba82fba110d93801d2..1dd0f4cf6c7f845f084de74059405bd81bf5f554 100644 (file)
@@ -4,7 +4,6 @@
 #warning: .*/compressed1.c:13: undefined reference to .bar.
 #nm: -n
 
-#failif
 #...
 [ \t]+U bar
-#...
+#pass
index 6373eea7e04c5139452bae716f5364c4e754518d..06d2562b8043bee9faa0efe1dd97d43eba905969 100644 (file)
@@ -4,7 +4,6 @@
 #readelf: -s --wide
 #warning: \A[^\n]*\.o[^\n]*In function `_start':\n[^\n]*: undefined reference to `foo'\Z
 
-#failif
 #...
  +[0-9]+: +[0-9a-f]+ +0 +NOTYPE +GLOBAL +DEFAULT +UND foo
-#...
+#pass