[llvm] [Object][Wasm] Use offset instead of index for Global address and store size (PR #81781)

Derek Schuff via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 14 15:31:31 PST 2024


dschuff wrote:

> On the other hand, the "address" of a global is kind of its index right? i.e. if you want to access a global you need to know its address (index) to pass to global.get/global.set.

Yes, this is an interesting difference in the meanings or use cases you might have for symbols. And in fact `getSymbolValue()` does still return indices for both globals and functions whereas `getSymbolAddress` now returns offsets. It started doing this for functions way back when Wouter added disassembly support IIUC, and now globals match. This does mean that the symbol's "address" doesn't match its "value", whereas IIUC it's usually the case that they are the same thing. In principle this could violate some assumption somewhere, but it's been that way a long time for functions and hasn't been a problem. I think it just so happens that the linker always uses the "value" (since for linking/relocation use cases you do want the index as you pointed out) and the binutils use the "address". So maybe it's ok?

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


More information about the llvm-commits mailing list