This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Suppress "STT_SECTION symbol should be defined" on .eh_frame, .debug*, .zdebug* and .gcc_except_table
ClosedPublic

Authored by MaskRay on Jun 3 2019, 10:08 PM.

Details

Summary

With -r or --emit-relocs, we warn STT_SECTION symbol should be defined
on relocations to discarded section symbol. This was added as an error
in rLLD319404, but was not so effective before D61583 (turned to a
warning).

Relocations from .eh_frame .debug* .zdebug* .gcc_except_table to
discarded .text are very common and somewhat expected. Don't warn/error
on them. As a reference, ld.bfd has a similar logic in
_bfd_elf_default_action_discarded() to allow these cases.

invalid-undef-section-symbol.test can be deleted as what it intended to
check is now covered by the updated comdat-discarded-reloc.s

Event Timeline

MaskRay created this revision.Jun 3 2019, 10:08 PM
MaskRay updated this revision to Diff 202857.Jun 3 2019, 10:46 PM
MaskRay retitled this revision from [ELF] Suppress "STT_SECTION symbol should be defined" warnings on .eh_frame, .debug* and .zdebug* to [ELF] Suppress "STT_SECTION symbol should be defined" on .eh_frame, .debug*, .zdebug* and .gcc_except_table.
MaskRay edited the summary of this revision. (Show Details)

In addition, allow .gcc_except_table

ruiu accepted this revision.Jun 4 2019, 5:18 AM

LGTM

ELF/InputSection.cpp
447–448

There is a newline in a little bit weird place. Is this what clang-format formatted?

Maybe you should write this using two assignments rather than writing it as a single line.

This revision is now accepted and ready to land.Jun 4 2019, 5:18 AM
MaskRay updated this revision to Diff 202923.Jun 4 2019, 6:28 AM

Use two assignments:

uint32_t SecIdx = cast<Undefined>(Sym).DiscardedSecIdx;
Elf_Shdr_Impl<ELFT> Sec =
    CHECK(File->getObj().sections(), File)[SecIdx];
This revision was automatically updated to reflect the committed changes.
MaskRay marked an inline comment as done.
test/ELF/comdat-discarded-reloc.s