aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2021-01-04 17:13:51 +1030
committerAlan Modra <amodra@gmail.com>2021-01-04 18:58:15 +1030
commit5b4293ba3c207ebdaea3631819b9459f0a10e761 (patch)
treee7f1bc6ae597de21c0a991644eb5a7887e8e7b68 /bfd
parentdd933805d10b0035659dfec40630c30a0b33aa4c (diff)
downloadgdb-5b4293ba3c207ebdaea3631819b9459f0a10e761.zip
gdb-5b4293ba3c207ebdaea3631819b9459f0a10e761.tar.gz
gdb-5b4293ba3c207ebdaea3631819b9459f0a10e761.tar.bz2
PR26822, How to prevent a STT_FILE with absolute path in the linked image
bfd/ PR 26822 * elflink.c (elf_link_input_bfd): Use the file base name in linker generated STT_FILE symbols. ld/ PR 26822 * testsuite/ld-arm/non-contiguous-arm2.d: Adjust STT_FILE symbol match. * testsuite/ld-arm/non-contiguous-arm3.d: Likewise. * testsuite/ld-arm/non-contiguous-arm5.d: Likewise. * testsuite/ld-arm/non-contiguous-arm6.d: Likewise. * testsuite/ld-i386/tlsbin.rd: Likewise. * testsuite/ld-i386/tlsbin2.rd: Likewise. * testsuite/ld-i386/tlsbindesc.rd: Likewise. * testsuite/ld-i386/tlsdesc.rd: Likewise. * testsuite/ld-i386/tlsnopic.rd: Likewise. * testsuite/ld-i386/tlspic.rd: Likewise. * testsuite/ld-i386/tlspic2.rd: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-n64t.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32.d: Likewise. * testsuite/ld-mips-elf/global-local-symtab-sort-o32t.d: Likewise. * testsuite/ld-plugin/pr17973.d: Likewise. * testsuite/ld-tic6x/shlib-1.rd: Likewise. * testsuite/ld-tic6x/shlib-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1b.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1r.rd: Likewise. * testsuite/ld-tic6x/shlib-app-1rb.rd: Likewise. * testsuite/ld-tic6x/shlib-noindex.rd: Likewise. * testsuite/ld-tic6x/static-app-1.rd: Likewise. * testsuite/ld-tic6x/static-app-1b.rd: Likewise. * testsuite/ld-tic6x/static-app-1r.rd: Likewise. * testsuite/ld-tic6x/static-app-1rb.rd: Likewise. * testsuite/ld-x86-64/tlsbin.rd: Likewise. * testsuite/ld-x86-64/tlsbin2.rd: Likewise. * testsuite/ld-x86-64/tlsbindesc.rd: Likewise. * testsuite/ld-x86-64/tlsdesc.rd: Likewise. * testsuite/ld-x86-64/tlspic.rd: Likewise. * testsuite/ld-x86-64/tlspic2.rd: Likewise. * testsuite/ld-xtensa/tlsbin.rd: Likewise. * testsuite/ld-xtensa/tlspic.rd: Likewise.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog6
-rw-r--r--bfd/elflink.c12
2 files changed, 13 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index a7cc3c8..0a472e5 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,9 @@
+2021-01-04 Alan Modra <amodra@gmail.com>
+
+ PR 26822
+ * elflink.c (elf_link_input_bfd): Use the file base name in
+ linker generated STT_FILE symbols.
+
2021-01-04 Nelson Chu <nelson.chu@sifive.com>
* elfxx-riscv.c (riscv_compare_subsets): Removed static.
diff --git a/bfd/elflink.c b/bfd/elflink.c
index 1dfed2f..448989a 100644
--- a/bfd/elflink.c
+++ b/bfd/elflink.c
@@ -10952,16 +10952,18 @@ elf_link_input_bfd (struct elf_final_link_info *flinfo, bfd *input_bfd)
files lack such, so that their symbols won't be
associated with a previous input file. It's not the
source file, but the best we can do. */
+ const char *filename;
have_file_sym = TRUE;
flinfo->filesym_count += 1;
memset (&osym, 0, sizeof (osym));
osym.st_info = ELF_ST_INFO (STB_LOCAL, STT_FILE);
osym.st_shndx = SHN_ABS;
- if (!elf_link_output_symstrtab (flinfo,
- (input_bfd->lto_output ? NULL
- : bfd_get_filename (input_bfd)),
- &osym, bfd_abs_section_ptr,
- NULL))
+ if (input_bfd->lto_output)
+ filename = NULL;
+ else
+ filename = lbasename (bfd_get_filename (input_bfd));
+ if (!elf_link_output_symstrtab (flinfo, filename, &osym,
+ bfd_abs_section_ptr, NULL))
return FALSE;
}