[clang] [Clang][Interpreter] Force GOT access for external data references (PR #201286)

Lang Hames via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 4 01:22:17 PDT 2026


lhames wrote:

> In clang-repl, R_*_32 relocations are emitted as direct 32-bit PC-relative references. A normal static linker can resolve references to distinct symbol through the GOT or Copy relocation, but clang-repl directly mmaps shared objects into memory and bypasses the static linker.

Can you be more specific about the relocations that you're seeing?

CodeGen usually requests a GOT entry (by selecting one of the GOT relocations and producing the necessary instruction sequence), and the linker just builds the requested GOT entry.

The usual caveat is hidden symbols:
```c
extern int __attribute__((visibility("hidden"))) X;
int getX() { return X; } // <- will typically emit 32-bit PC-relative reference
```

The problem in this case is that ClangRepl probably isn't doing slab allocation by default, in which case switching to a slab-based allocator is the best answer.

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


More information about the cfe-commits mailing list