This is an archive of the discontinued LLVM Phabricator instance.

[ELF] Add PT_RISCV_ATTRIBUTES program header
ClosedPublic

Authored by MaskRay on Jun 3 2023, 7:28 AM.

Details

Summary

Close https://github.com/llvm/llvm-project/issues/63084

Unlike AArch32, RISC-V defines PT_RISCV_ATTRIBUTES to include the
SHT_RISCV_ATTRIBUTES section. There is no real-world use case yet.

We place PT_RISCV_ATTRIBUTES after PT_GNU_STACK, similar to PT_ARM_EXIDX. GNU ld
places PT_RISCV_ATTRIBUTES earlier, but the placement should not matter.

Link: https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/71

Diff Detail

Event Timeline

MaskRay created this revision.Jun 3 2023, 7:28 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 3 2023, 7:29 AM
MaskRay requested review of this revision.Jun 3 2023, 7:29 AM
MaskRay added a comment.EditedJun 3 2023, 7:31 AM

The experimental partitions feature is not tested. I don't think anyone cares about its interaction with PT_RISCV_ATTRIBUTES and don't think a test for the , partNo part is necessary.

MaskRay updated this revision to Diff 528107.Jun 3 2023, 7:42 AM
MaskRay edited the summary of this revision. (Show Details)

add Dxxxx link to release note
fix test

tested applied on 16.0.5, works for the original strip failure case for me as well.

asb accepted this revision.Jun 6 2023, 1:13 AM

LGTM.

This revision is now accepted and ready to land.Jun 6 2023, 1:13 AM

Relatedly, llvm-objcopy --remove-section=.riscv.attributes probably should change the PT_RISCV_ATTRIBUTES program header to a PT_NONE. I'll handle this later.

MaskRay retitled this revision from [ELF] Add PT_RISCV_ATTRIBUTES to [ELF] Add PT_RISCV_ATTRIBUTES program header.Jun 6 2023, 1:04 PM
This revision was landed with ongoing or failed builds.Jun 6 2023, 1:06 PM
This revision was automatically updated to reflect the committed changes.

I was misled. I forgot to ask myself again why this program header type is needed:)

I created https://github.com/riscv-non-isa/riscv-elf-psabi-doc/pull/386 to propose that we remove PT_RISCV_ATTRIBUTES instead.

lld/test/ELF/riscv-attributes.s
72

GNU ld sets p_memsz to 0. I forgot to notice it.