This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Drop undefined local symbols from symtab?
- From: Alan Modra <amodra at gmail dot com>
- To: binutils at sourceware dot org
- Date: Wed, 18 Feb 2015 21:57:16 +1030
- Subject: Drop undefined local symbols from symtab?
- Authentication-results: sourceware.org; auth=none
Does anyone see any harm in dropping undefined local symbols from
.symtab? I've been meaning to do this for a while, mainly to get rid
of undefined ppc64 "dot-symbols".
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 44fc2bb..138c4ba 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-18 Alan Modra <amodra@gmail.com>
+
+ * elflink.c (elf_link_input_bfd): Drop undefined local syms.
+ (elf_link_output_extsym): Likewise. Tidy. Expand comment.
+
2015-02-17 Alan Modra <amodra@gmail.com>
PR ld/17975
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 038e43d..f4c5398 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -8902,8 +8902,9 @@ 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)
@@ -8929,12 +8930,11 @@ 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 unless it is a forced local symbol or a
- STT_GNU_IFUNC symbol. */
+ 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. */
if (strip
&& h->dynindx == -1
&& h->type != STT_GNU_IFUNC
@@ -9207,7 +9207,13 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data)
/* 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)
+ if (strip)
+ return TRUE;
+ if ((input_sec->flags & SEC_EXCLUDE) != 0)
+ return TRUE;
+ if (input_sec == bfd_und_section_ptr
+ && !h->root.linker_def
+ && ELF_ST_BIND (sym.st_info) == STB_LOCAL)
return TRUE;
/* Output a FILE symbol so that following locals are not associated
@@ -9455,8 +9461,9 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
*ppsection = isec;
- /* Don't output the first, undefined, symbol. */
- if (ppsection == flinfo->sections)
+ /* Don't output the first, undefined, symbol. In fact, don't
+ output any undefined local symbol. */
+ if (isec == bfd_und_section_ptr)
continue;
if (ELF_ST_TYPE (isym->st_info) == STT_SECTION)
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 43cf4e8..41b37af 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,8 @@
+2015-02-18 Alan Modra <amodra@gmail.com>
+
+ * emultempl/elf32.em (gld${EMULATION_NAME}_before_allocation): Set
+ linker_def on __ehdr_start.
+
2015-02-14 H.J. Lu <hongjiu.lu@intel.com>
PR ld/17973
diff --git a/ld/emultempl/elf32.em b/ld/emultempl/elf32.em
index 618e20a..0f22570 100644
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1570,6 +1570,7 @@ ${ELF_INTERPRETER_SET_DEFAULT}
as it was. */
ehdr_start->root.type = ehdr_start_save.type;
ehdr_start->root.u = ehdr_start_save.u;
+ ehdr_start->root.linker_def = 1;
}
}
diff --git a/ld/testsuite/ChangeLog b/ld/testsuite/ChangeLog
index 64f0871..b8aeb0a 100644
--- a/ld/testsuite/ChangeLog
+++ b/ld/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2015-02-18 Alan Modra <amodra@gmail.com>
+
+ * ld-aarch64/gc-tls-relocs.d,
+ * ld-powerpc/tlsexe.r, * ld-powerpc/tlsexetoc.r,
+ * ld-powerpc/tlsso.r, * ld-powerpc/tlstocso.r: Update.
+
2015-02-17 Alan Modra <amodra@gmail.com>
PR ld/17975
diff --git a/ld/testsuite/ld-aarch64/gc-tls-relocs.d b/ld/testsuite/ld-aarch64/gc-tls-relocs.d
index 191647c..480d869 100644
--- a/ld/testsuite/ld-aarch64/gc-tls-relocs.d
+++ b/ld/testsuite/ld-aarch64/gc-tls-relocs.d
@@ -17,7 +17,6 @@ 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
diff --git a/ld/testsuite/ld-powerpc/tlsexe.r b/ld/testsuite/ld-powerpc/tlsexe.r
index 443bae8..94e5272 100644
--- a/ld/testsuite/ld-powerpc/tlsexe.r
+++ b/ld/testsuite/ld-powerpc/tlsexe.r
@@ -98,9 +98,8 @@ 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|(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))
+.* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve
+.* NOTYPE +LOCAL +DEFAULT +7 .*\.plt_call\.__tls_get_addr(|_opt)
.* GLOBAL +DEFAULT +UND gd
.* GLOBAL +DEFAULT +9 le0
.* GLOBAL +DEFAULT +9 ld0
diff --git a/ld/testsuite/ld-powerpc/tlsexetoc.r b/ld/testsuite/ld-powerpc/tlsexetoc.r
index bb6462f..7b55281 100644
--- a/ld/testsuite/ld-powerpc/tlsexetoc.r
+++ b/ld/testsuite/ld-powerpc/tlsexetoc.r
@@ -98,9 +98,8 @@ 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|(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))
+.* NOTYPE +LOCAL +DEFAULT +7 __glink_PLTresolve
+.* 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
diff --git a/ld/testsuite/ld-powerpc/tlsso.r b/ld/testsuite/ld-powerpc/tlsso.r
index 3a5b808..e0a3a75 100644
--- a/ld/testsuite/ld-powerpc/tlsso.r
+++ b/ld/testsuite/ld-powerpc/tlsso.r
@@ -116,7 +116,6 @@ 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
diff --git a/ld/testsuite/ld-powerpc/tlstocso.r b/ld/testsuite/ld-powerpc/tlstocso.r
index 075e303..0006db9 100644
--- a/ld/testsuite/ld-powerpc/tlstocso.r
+++ b/ld/testsuite/ld-powerpc/tlstocso.r
@@ -112,7 +112,6 @@ 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
--
Alan Modra
Australia Development Lab, IBM