How to debug if LTO generate wrong code?

Hi Joerg,
My firmware case is I need load my firmware to run in high address which is hardware required. It is not that my firmware really need large static data and text code. My firmware modules are shared library (like a DLL) built with "-fpic", and firmware loader will load them to high address (larger than 2GB). I think this need is quite common to system software, like firmware, driver and kernel mode code.

Steven Shi
Intel\SSG\STO\UEFI Firmware

Tel: +86 021-61166522
iNet: 821-6522

It sounds more like there a confusion about what symbols are internal
and what not. The normal code model on AMD64 requires code and data to
fit into 2GB, but non-local symbols are accessed indirectly. That
doesn't happen in your case. For functions, that's normally partially
the job of the linker (via stubs), but for data the compiler has to be
aware of it. The load address is irrelevant for PIC.

Joerg

Yes, the "normal" code model you mentioned is the small code model, which use RIP-relative addressing, but my firmware need large code model which can reside anywhere in the full 64-bit address space. So, I need LLVM LTO support large code model.

Steven Shi
Intel\SSG\STO\UEFI Firmware

Tel: +86 021-61166522
iNet: 821-6522