RE: [PATCH] microblaze: neutralise relocations against discarded sections
"Frager, Neal" <[email protected]>
| Newsgroups | gmane.comp.gnu.binutils |
|---|---|
| Message-ID | <BL1PR12MB503294C42BFF4BD5C809D80CF0DB2@BL1PR12MB5032.namprd12.prod.outlook.com> |
AMD General Hello Sam, > microblaze_elf_relocate_section does not handle relocations against > symbols defined in sections discarded by linkonce or comdat handling. > bfd/elf32-microblaze.c contains no RELOC_AGAINST_DISCARDED_SECTION at > all, where 60 other bfd/elf*.c files use it. The relocation survives and > resolves against a dead symbol, so debug sections end up holding garbage > where zero is expected: > ld-elf/linkonce2 > regexp "^.*(NONE|unused|UNUSED).*\*ABS\*$" > line "00000000 R_MICROBLAZE_32 foo" > ld-discard/zero-range > regexp "^ 0000 (01)?000000(01)? (01)?000000(01)? 00000000 00000000 .*$" > line " 0000 00000000 00000002 00000000 00000000 ................" > sym_hashes is checked for NULL as RELOC_FOR_GLOBAL_SYMBOL does, since this > lookup runs before that macro is reached. elf_sym_hashes is left NULL for > an object with no global symbols, the allocation in > elf_link_add_object_symbols being gated on extsymcount, so the check is > not only for the malformed input its comment there mentions. > Most backends put the check after symbol resolution and before the > bfd_link_relocatable early exit. This one resolves the symbol separately > in each of two branches, and the relocatable branch returns early for > global symbols, which is exactly the case ld-elf/linkonce2 exercises. > The defining section is therefore looked up once before either branch, > which covers both the final and the relocatable link without > restructuring the function. > microblaze_elf_howto_table is an array of pointers, and > R_MICROBLAZE_TEXTREL_32_LO has no entry in microblaze_elf_howto_raw, so > howto can be NULL for a type that is in range. Relaxation creates that > type and _bfd_clear_contents reads howto->size, so the call is guarded, as > elf32-ppc.c guards its own array of howto pointers. Such a relocation is > left alone rather than neutralised, as before. > Fixes four existing tests on microblaze-elf: > ld-discard/zero-range > ld-discard/zero-rel > ld-elf/linkonce1 > ld-elf/linkonce2 > ld/testsuite goes from 476 passes and 4 unexpected failures to 480 and 0. > gas and binutils result lists are byte-identical. No test changes state > in the other direction. > bfd/ > * elf32-microblaze.c (microblaze_elf_relocate_section): Look up > the section defining the symbol and neutralise relocations > against discarded sections, skipping relocation types with no > howto table entry and objects with no symbol hash table. > Signed-off-by: Sam Price <[email protected]> > Assisted-by: Claude (Anthropic) Thank you for fixing these! Reviewed-by: Neal Frager <[email protected]> Best regards, Neal Frager AMD