On 3 August 2016 at 08:48, Shi, Steven <steven.shi@...> wrote:
This adds support for LLVM 3.8.x in LTO mode for IA32 and X64. CLANG38 enable LLVM Link Time Optimization (LTO) and code size optimization flag (-Oz) by default for aggressive code size improvement. CLANG38 X64 code is small code model + PIE.
CLANG LTO needs PIE in link flags to generate PIE code correctly, otherwise the PIE is not really enabled. (e.g. OvmfPkgX64 will hang in 64bits SEC at high address because of small model code displacement overflow).
This is probably caused by the same issue I am addressing with the series I sent out yesterday, to pass the CC flags to the DLINK command.
The reason is that code is generated by the link pass, so it needs to see the same -fpie -mcmodel=small options that we passed to the compiler as wel.
Could you check whether replacing '-Wl,-pie' with -fpie does the trick as well? As I mentioned before, creating a PIE executable at link time is not the same as generatic position independent code at compile time (whether it is via $(CC) or via $(DLINK)). The PIE executable will contain a .rela section that partially overlaps with other absolute relocations, so it is best to avoid it.
[Steven]: I just tried it. No, replacing '-Wl,-pie' with -fpie cannot works for clang38. With -fpie in link flags, the OvmfPkgX64 still hang in 64bits SEC at high address.