This is an archive of the discontinued LLVM Phabricator instance.

[AARCH64][ELF][llvm-readobj] Support for AArch64 .note.gnu.property
ClosedPublic

Authored by peter.smith on May 29 2019, 8:02 AM.

Details

Summary

ELF for the 64-bit Arm Architecture defines a processor specific property type GNU_PROPERTY_AARCH64_FEATURE_1_AND as GNU_PROPERTY_LOPROC. This property works in a similar way to the existing X86 processor specific property GNU_PROPERTY_GNU_X86_FEATURE_1_AND.

Two feature bits are defined for GNU_PROPERTY_AARCH64_FEATURE_1_AND:

  • GNU_PROPERTY_AARCH64_FEATURE_1_BTI 0x1
  • GNU_PROPERTY_AARCH64_FEATURE_1_PAC 0x2

This patch defines the property, feature bits and implements support for printing in llvm-readobj.

The overall destination is support for BTI and PAC in LLD.

The ELF for the 64-bit Arm Architecture spec with the above features defined can be found at: https://developer.arm.com/docs/ihi0056/latest/elf-for-the-arm-64-bit-architecture-aarch64-abi-2019q1-documentation

Diff Detail

Repository
rL LLVM

Event Timeline

peter.smith created this revision.May 29 2019, 8:02 AM
grimar added inline comments.May 30 2019, 2:33 AM
tools/llvm-readobj/ELFDumper.cpp
3748 ↗(On Diff #201913)

Seems you should be able to share the logic with GNU_PROPERTY_X86_FEATURE_1_AND?

i.e.

case GNU_PROPERTY_X86_FEATURE_1_AND:
case GNU_PROPERTY_AARCH64_FEATURE_1_AND:
....

OS << (Type == GNU_PROPERTY_AARCH64_FEATURE_1_AND) ?
  "aarch64 feature: " : "x86 feature: ";
...

and so on. Will it be better?

Updated diff to share more of the code with the GNU_PROPERTY_GNU_X86_FEATURE_1_AND. The processor specific feature bits will overlap so these need to be protected. I think this is better than the previous version as we are sharing the parsing code.

grimar accepted this revision.May 30 2019, 3:05 AM

LGTM

test/tools/llvm-readobj/aarch64-note-gnu-property.s
4 ↗(On Diff #202145)

nit: I think we use llvm-readobj and llvm-readelf usually instead of specifying -elf-output-style explicitly.

This revision is now accepted and ready to land.May 30 2019, 3:05 AM
MaskRay accepted this revision.May 30 2019, 3:15 AM
MaskRay added a subscriber: MaskRay.
MaskRay added inline comments.
test/tools/llvm-readobj/aarch64-note-gnu-property.s
1 ↗(On Diff #202145)

This line is not needed. llvm-readobj doesn't use any llvm/lib/Target/AArch64 code (I guess that is what aarch64-registered-target is about)

Also consider moving the test under the AArch64 directory since it is there?

grimar added inline comments.May 30 2019, 3:19 AM
test/tools/llvm-readobj/aarch64-note-gnu-property.s
1 ↗(On Diff #202145)

I think this is for llvm-mc call below..
We can avoid it with using yaml instead, but perhaps it is not that really valuable.

Thanks for the reviews, I'll move the test to the AArch64 dir and lose the top line. Will do that on Monday as I'll be out of office tomorrow.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJun 4 2019, 4:25 AM