[PATCH] elf: Use elf_link_first_hash_entry for first_hash
Alan Modra
amodra@gmail.com
Sat Apr 6 01:51:05 GMT 2024
Looks like we still have a problem with accesses to freed memory.
This following is from link stage of LTO 1 test under valgrind.
==1443263== Invalid read of size 1
==1443263== at 0x484CFE4: strcmp (vg_replace_strmem.c:939)
==1443263== by 0x56E16C: bfd_hash_lookup (hash.c:564)
==1443263== by 0x5A3C8F: elf_link_add_to_first_hash (elflink.c:4316)
==1443263== by 0x5AE60F: elf_link_add_object_symbols (elflink.c:5663)
==1443263== by 0x5B0672: bfd_elf_link_add_symbols (elflink.c:6333)
==1443263== by 0x41448F: load_symbols (ldlang.c:3129)
==1443263== by 0x4149D8: open_input_bfds (ldlang.c:3621)
==1443263== by 0x414968: open_input_bfds (ldlang.c:3569)
==1443263== by 0x4166A2: lang_process (ldlang.c:8162)
==1443263== by 0x4194D5: main (ldmain.c:504)
==1443263== Address 0x525e230 is 192 bytes inside a block of size 4,064 free'd
==1443263== at 0x484810F: free (vg_replace_malloc.c:974)
==1443263== by 0x8D4D87: objalloc_free_block (objalloc.c:248)
==1443263== by 0x5AEACC: elf_link_add_object_symbols (elflink.c:5790)
==1443263== by 0x5B0672: bfd_elf_link_add_symbols (elflink.c:6333)
==1443263== by 0x41448F: load_symbols (ldlang.c:3129)
==1443263== by 0x4149D8: open_input_bfds (ldlang.c:3621)
==1443263== by 0x414968: open_input_bfds (ldlang.c:3569)
==1443263== by 0x4166A2: lang_process (ldlang.c:8162)
==1443263== by 0x4194D5: main (ldmain.c:504)
==1443263== Block was alloc'd at
==1443263== at 0x4845828: malloc (vg_replace_malloc.c:431)
==1443263== by 0x8D4C10: _objalloc_alloc (objalloc.c:159)
==1443263== by 0x56E2EF: bfd_hash_allocate (hash.c:756)
==1443263== by 0x5833B8: _bfd_x86_elf_link_hash_newfunc (elfxx-x86.c:627)
==1443263== by 0x56DF72: bfd_hash_insert (hash.c:611)
==1443263== by 0x56E19E: bfd_hash_lookup (hash.c:586)
==1443263== by 0x56FE22: bfd_link_hash_lookup (linker.c:515)
==1443263== by 0x5A2D1B: elf_link_hash_lookup (elf-bfd.h:779)
==1443263== by 0x5AA12B: _bfd_elf_merge_symbol (elflink.c:1129)
==1443263== by 0x5AB3DB: _bfd_elf_add_default_symbol (elflink.c:2133)
==1443263== by 0x5AF282: elf_link_add_object_symbols (elflink.c:5413)
==1443263== by 0x5B0672: bfd_elf_link_add_symbols (elflink.c:6333)
The objalloc_free_block is the one when restoring the linker hash
table to as it was prior to adding symbols for an as-needed library
that was found to not be needed. I'd rather not fix this by just
copying the name when adding symbols to first_hash, if at all
possible.
--
Alan Modra
Australia Development Lab, IBM
More information about the Binutils
mailing list