The load command is currently specific to arm64 and holds information
for instruction rewriting, e.g. converting a GOT load to an ADR to
compute a local address.
(On ELF the information is usually conveyed by relocations, e.g.
R_X86_64_REX_GOTPCRELX, R_PPC64_TOC16_HA)
Details
Details
Diff Detail
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Comment Actions
Regarding tests:
loh.s:
.text .align 2 _test: L1: adrp x0, _foo@PAGE L2: add x0, x0, _foo@PAGEOFF .loh AdrpAdd L1, L2 .data _foo: .long 0
llvm-mc -filetype=obj -triple=arm64-apple-darwin loh.s -o loh.o
llvm-objdump --macho --link-opt-hints loh.o
will print them.
Unfortunately, at the moment ObjectYAML doesn't support linker optimization hints (see MachOYAML.h, struct LinkEditData),
so ideally it'd be good to extend ObjectYAML (it should be similar to other things living inside LinkEdit),
alternatively, one can create a test using assembly & llvm-mc.
llvm/tools/llvm-objcopy/MachO/MachOReader.cpp | ||
---|---|---|
341 | nit: to hide these details one can introduce readLinkerOptimizationHints void MachOReader::readLinkerOptimizationHints(Object &Obj) { return readLinkData(*Obj, Obj->LinkerOptimizationHintCommandIndex, Obj->LinkerOptimizationHint); } |
nit: to hide these details one can introduce readLinkerOptimizationHints
(similarly to readDataInCode, readFunctionStartsData etc)
which would call this helper method (readLinkData) with the right arguments: