[PATCH] D150870: [lld][Arm] Big Endian - Byte invariant support.

Simi Pallipurath via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 18 07:29:49 PDT 2023


simpal01 created this revision.
Herald added subscribers: kristof.beyls, arichardson, emaste.
Herald added a reviewer: MaskRay.
Herald added a project: All.
simpal01 requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Arm has BE8 big endian configuration called
a byte-invariant(every byte has the same address
on little and big-endian systems).

When in BE8 mode:

1. Instructions are big-endian in objects but little-endian in executables.
2. Data is big-endian.
3. ELF files are big-endian.

To support BE8 without an ABI break for relocatable
objects,the linker takes on the responsibility of
changing the endianness of instructions. At a high
level the only difference between BE32 and BE8 in
the linker is that for BE8:

1. The linker sets the flag EF_ARM_BE8 in the ELF header.
2. The linker endian reverses the instructions, but not data.

This patch adds BE8 big endian support for Arm. To
endian reverse the instructions we'll need access
to the mapping symbols. Code sections can contain a
mix of Arm, Thumb and literal data. We need to endian
reverse Arm instructions as words, Thumb instructions
as half-words and ignore literal data.The only way to
find these transitions precisely is by using mapping
symbols. The instruction reversal will need to take
place after relocation. For Arm BE8 code sections
(Section has SHF_EXECINSTR flag ) we inserted a step
after relocation to endian reverse the instructions.
The implementation strategy i have used here is to
write all sections BE32  including SyntheticSections
then endian reverse all code in InputSections with
via mapping symbols.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150870

Files:
  lld/ELF/Arch/ARM.cpp
  lld/ELF/Config.h
  lld/ELF/Driver.cpp
  lld/ELF/Options.td
  lld/ELF/OutputSections.cpp
  lld/ELF/Target.h
  lld/test/ELF/arm-be8-check.s
  lld/test/ELF/arm-be8-thunks.s
  lld/test/ELF/arm-bl-v6.s
  lld/test/ELF/arm-data-relocs.s
  lld/test/ELF/arm-exidx-emit-relocs.s
  lld/test/ELF/arm-exidx-relocatable.s
  lld/test/ELF/arm-exidx-sentinel-norelocatable.s
  lld/test/ELF/arm-header.s
  lld/test/ELF/arm-mov-relocs.s
  lld/test/ELF/arm-plt-reloc.s
  lld/test/ELF/arm-thumb-plt-reloc.s
  lld/test/ELF/arm-thunk-arm-thumb-reuse.s
  lld/test/ELF/arm-thunk-edgecase.s
  lld/test/ELF/arm-thunk-largesection.s
  lld/test/ELF/arm-thunk-linkerscript-dotexpr.s
  lld/test/ELF/arm-thunk-linkerscript.s
  lld/test/ELF/arm-thunk-nosuitable.s
  lld/test/ELF/arm-thunk-re-add.s
  lld/test/ELF/arm-thunk-reuse.s
  lld/test/ELF/arm-thunk-section-too-large.s
  lld/test/ELF/arm-thunk-toolargesection.s
  lld/test/ELF/arm-v5-reloc-error.s
  lld/test/ELF/emulation-arm.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150870.523373.patch
Type: text/x-patch
Size: 40756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230518/fad0da01/attachment.bin>


More information about the llvm-commits mailing list