diff options
author | Nick Clifton <nickc@redhat.com> | 2017-10-23 18:16:49 +0100 |
---|---|---|
committer | Nick Clifton <nickc@redhat.com> | 2017-10-23 18:16:49 +0100 |
commit | 66cae56016a12f7cbdc94be6f82c1cad1c59b521 (patch) | |
tree | a89554827cf870a421e3af26f6b7d6c389abefe4 /bfd/elflink.c | |
parent | fe4e2a3c9281851c9da99a6e36a2bc96e4279476 (diff) |
Make sure that undefined symbols added to the linker command line via the -u option appear in the output executable, if they have not been resolved.
PR 22319
bfd * elflink.c (elf_link_output_extsym): Keep global undefined
symbols if they have been marked as needed.
ld * testsuite/ld-elf/pr22310.s: New test source file.
* testsuite/ld-elf/pr22310.d: New test driver.
* testsuite/ld-mmix/undef-3.d: Update expected output from readelf.
Diffstat (limited to 'bfd/elflink.c')
-rw-r--r-- | bfd/elflink.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/bfd/elflink.c b/bfd/elflink.c index b401e68df6..de13d04c89 100644 --- a/bfd/elflink.c +++ b/bfd/elflink.c @@ -9910,8 +9910,11 @@ elf_link_output_extsym (struct bfd_hash_entry *bh, void *data) relocatable output or when needed for --emit-relocs. */ else if (input_sec == bfd_und_section_ptr && h->indx != -2 + /* PR 22319 Do not strip global undefined symbols marked as being needed. */ + && (h->mark != 1 || ELF_ST_BIND (sym.st_info) != STB_GLOBAL) && !bfd_link_relocatable (flinfo->info)) return TRUE; + /* Also strip others that we couldn't earlier due to dynamic symbol processing. */ if (strip) |