Skip to content

[ELD] Add GNU property support for X86 and RISC-V - #2089

Open
Rachit Mehta (rachitmeht) wants to merge 1 commit into
qualcomm:mainfrom
rachitmeht:fix/gnu-property-drop
Open

Rachit Mehta (rachitmeht) wants to merge 1 commit into
qualcomm:mainfrom
rachitmeht:fix/gnu-property-drop

Conversation

@rachitmeht

Copy link
Copy Markdown
Contributor

Generalize the existing AArch64 GNU property handling and enable FEATURE_1_AND merging for x86-64, i386, and RISC-V.

Emit correctly sized and aligned ELF32 and ELF64 property notes, and add tests for feature merging, missing notes, linker scripts, discarded notes, and malformed inputs.

Resolves #1680

Comment thread lib/Fragment/CMakeLists.txt
Comment thread lib/Target/GNULDBackend.cpp
return false;
}
const auto *Nhdr = reinterpret_cast<const Elf_Nhdr *>(Data.data());
const uint64_t NoteSize = Nhdr->getSize(S->getAddrAlign());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please check if there is any valid case where S->getAddrAlign might be 0? In ELF, the alignment of 0 typically means alignment of 1, but Nhdr->getSize(0) can result in assertion failure. If this code was the same as in the original AArch64, then can you please leave it as-is for now and open an issue to track this.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I could not find a normal assembler-only way to generate such a case.

Comment on lines +223 to +224
if (S->getKind() == LinkerSectionKind::GNUProperty)
return GNULDBackend::readSection(pInput, S);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this if-condition required? Wouldn't we fallback to the same GNULDBackend::readSection(...) at line 235 without it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for .section .note.gnu.property, "ax", @note isCode() will be true, and it will not reach GNULDBackend::readSection(...).

Generalize the existing AArch64 GNU property handling and enable
FEATURE_1_AND merging for x86-64, i386, and RISC-V.

Emit correctly sized and aligned ELF32 and ELF64 property notes, and add
tests for feature merging, missing notes, linker scripts, discarded
notes, and malformed inputs.

Resolves qualcomm#1680

Signed-off-by: Rachit Mehta <rachmeht@qti.qualcomm.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ELD drops .note.gnu.property

2 participants