[lld] [lld][AArch64] Fix handling of SHT_REL relocation addends. (PR #98291)

Peter Smith via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 11 14:19:32 PDT 2024


================
@@ -366,11 +421,13 @@ static void write32AArch64Addr(uint8_t *l, uint64_t imm) {
   write32le(l, (read32le(l) & ~mask) | immLo | immHi);
 }
 
-static void or32le(uint8_t *p, int32_t v) { write32le(p, read32le(p) | v); }
+static void writeBits32le(uint8_t *p, int32_t v, uint32_t mask) {
+  write32le(p, (read32le(p) & ~mask) | v);
+}
 
 // Update the immediate field in a AARCH64 ldr, str, and add instruction.
-static void or32AArch64Imm(uint8_t *l, uint64_t imm) {
-  or32le(l, (imm & 0xFFF) << 10);
+static void write32AArch64Imm(uint8_t *l, uint64_t imm) {
----------------
smithp35 wrote:

I think we could call this `write32Imm12` is the AArch64 is implicit from the filename, and this only writes imm12 immediates (I can't see any other AArch64 instruction that uses an imm12 in a different bit position).

Only a suggestion, not got a strong opinion.

https://github.com/llvm/llvm-project/pull/98291


More information about the llvm-commits mailing list