[all-commits] [llvm/llvm-project] bbc5d9: [llvm][MC][ARM][Assembly] Emit relocations for LDR...
Eleanor Bonnici via All-commits
all-commits at lists.llvm.org
Sat Nov 25 04:36:17 PST 2023
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: bbc5d9fe427362f3fec8d147d5f7bc2d39b08e44
https://github.com/llvm/llvm-project/commit/bbc5d9fe427362f3fec8d147d5f7bc2d39b08e44
Author: Eleanor Bonnici <eleanor.bonnici at arm.com>
Date: 2023-11-25 (Sat, 25 Nov 2023)
Changed paths:
M llvm/lib/Target/ARM/MCTargetDesc/ARMAsmBackend.cpp
M llvm/lib/Target/ARM/MCTargetDesc/ARMELFObjectWriter.cpp
A llvm/test/MC/ARM/pcrel-arm-ldr-imm8-relocs.s
M llvm/test/MC/ARM/pcrel-global.s
A llvm/test/MC/ARM/pcrel-ldr-relocs.s
A llvm/test/MC/ARM/pcrel-thumb-ldr2-relocs.s
M llvm/test/MC/ARM/thumb1-relax-ldrlit.s
Log Message:
-----------
[llvm][MC][ARM][Assembly] Emit relocations for LDRs (#72873)
It's possible (though inadvisable) to use LDR and refer to labels in
different
sections. In the Arm state, the assembler resolves the LDR instruction
without
emitting a relocation. That's incorrect because the assembler cannot
make any
assumptions about the relative position of the sections and the compiler
output
is therefore wrong.
This patch ensures relocations are generated for all `LDR <Rt...>,
label`
instructions in the Arm state (little endian). This is not necessary
when the
label is in the same section but the relocation is now generated
regardless.
Instructions that now generate relocations have been removed from the
pcrel-global.s test.
Fortunately, LLD already implements the generated relocations and can
fix LDR
instructions when the symbol is in a different section, or report an
error if
the offset is too large for the immediate field in the particular LDR's
encoding.
The patch to address this problem for big endian targets will follow, as
well
as a fix for ADR that exhibits a similar behavior.
More information about the All-commits
mailing list