diff options
author | Jan Beulich <jbeulich@suse.com> | 2022-05-19 12:45:55 +0200 |
---|---|---|
committer | Jan Beulich <jbeulich@suse.com> | 2022-05-19 12:45:55 +0200 |
commit | 20bed3bb3579d581b909e2319523331cd76bca57 (patch) | |
tree | fe1f421b9587443ffcf3e23b8266e1c112f7d80d /bfd/cofflink.c | |
parent | COFF/PE: keep linker version during objcopy / strip (diff) | |
download | binutils-gdb-20bed3bb3579d581b909e2319523331cd76bca57.tar.gz binutils-gdb-20bed3bb3579d581b909e2319523331cd76bca57.tar.bz2 binutils-gdb-20bed3bb3579d581b909e2319523331cd76bca57.zip |
COFF: use hash for string table also when copying / stripping
Otherwise the string table may grow and hence e.g. change a final binary
(observed with PE/COFF ones) even if really there's no change. Doing so
in fact reduces the overall amount of code, and in particular the number
of places which need to remain in sync.
Afaics there's no real equivalent to the "traditional_format" field used
when linking, so hashing is always enabled when copying / stripping.
Diffstat (limited to 'bfd/cofflink.c')
-rw-r--r-- | bfd/cofflink.c | 54 |
1 files changed, 5 insertions, 49 deletions
diff --git a/bfd/cofflink.c b/bfd/cofflink.c index 69e6df61191..92e780733fc 100644 --- a/bfd/cofflink.c +++ b/bfd/cofflink.c @@ -896,10 +896,8 @@ _bfd_coff_final_link (bfd *abfd, asymbol *sym = bfd_get_outsymbols (sub) [i]; file_ptr pos; struct internal_syment isym; - union internal_auxent iaux; - bfd_size_type string_size = 0, indx; bfd_vma written = 0; - bool rewrite = false, hash; + bool rewrite = false; if (! (sym->flags & BSF_LOCAL) || (sym->flags & (BSF_SECTION_SYM | BSF_DEBUGGING_RELOC @@ -925,54 +923,12 @@ _bfd_coff_final_link (bfd *abfd, * symesz; if (bfd_seek (abfd, pos, SEEK_SET) != 0) goto error_return; - if (! coff_write_alien_symbol(abfd, sym, &isym, &iaux, &written, - &string_size, NULL, NULL)) + if (! coff_write_alien_symbol(abfd, sym, &isym, &written, + flaginfo.strtab, + !flaginfo.info->traditional_format, + NULL, NULL)) goto error_return; - hash = !flaginfo.info->traditional_format; - - if (string_size >= 6 && isym.n_sclass == C_FILE - && ! isym._n._n_n._n_zeroes && isym.n_numaux) - { - indx = _bfd_stringtab_add (flaginfo.strtab, ".file", hash, - false); - if (indx == (bfd_size_type) -1) - goto error_return; - isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; - bfd_coff_swap_sym_out (abfd, &isym, flaginfo.outsyms); - if (bfd_seek (abfd, pos, SEEK_SET) != 0 - || bfd_bwrite (flaginfo.outsyms, symesz, - abfd) != symesz) - goto error_return; - string_size -= 6; - } - - if (string_size) - { - indx = _bfd_stringtab_add (flaginfo.strtab, - bfd_asymbol_name (sym), hash, - false); - if (indx == (bfd_size_type) -1) - goto error_return; - if (isym.n_sclass != C_FILE) - { - isym._n._n_n._n_offset = STRING_SIZE_SIZE + indx; - bfd_coff_swap_sym_out (abfd, &isym, flaginfo.outsyms); - rewrite = true; - } - else - { - BFD_ASSERT (isym.n_numaux == 1); - iaux.x_file.x_n.x_n.x_offset = STRING_SIZE_SIZE + indx; - bfd_coff_swap_aux_out (abfd, &iaux, isym.n_type, C_FILE, - 0, 1, flaginfo.outsyms + symesz); - if (bfd_seek (abfd, pos + symesz, SEEK_SET) != 0 - || bfd_bwrite (flaginfo.outsyms + symesz, symesz, - abfd) != symesz) - goto error_return; - } - } - if (isym.n_sclass == C_FILE) { if (flaginfo.last_file_index != -1) |