[PATCH] D27041: [ELF] - Disable emiting multiple output sections when merging is disabled.
George Rimar via llvm-commits
llvm-commits at lists.llvm.org
Thu Nov 24 00:58:05 PST 2016
grimar added a comment.
In https://reviews.llvm.org/D27041#604490, @ruiu wrote:
> I think I do not understand what this patch is trying to address. Did you mean that FreeBSD EFI loader passes -O0 to linker?
No it doesn't. My point is next:
For linkerscript we take "M" and "S" flags in account:
uintX_t Flags = C->Flags & (SHF_MERGE | SHF_STRINGS);
That is done because currently our implementation requires one output section per "kind",
what is different from what gnu linkers do.
With -O0 sections metging is disabled:
bool elf::ObjectFile<ELFT>::shouldMerge(const Elf_Shdr &Sec) {
if (Config->Optimize == 0)
return false;
In that case there is no point to create more output sections, we can combine them as regular into single section.
Currently that is the only way to get output similar to ld/gold. And currently that way broken.
Returning o EFI loader. Change above is useful for investigation of broken files, including the loader.
Currently LLD output for loader is:
[ 4] .data PROGBITS 0000000000058000 00059000
0000000000006355 0000000000000001 AMS 0 0 1
[ 5] .got PROGBITS 0000000000068520 0005f520
00000000000004a0 0000000000000000 WA 0 0 8
[ 6] .data PROGBITS 000000000005e360 00055360
000000000000a142 0000000000000000 WA 0 0 16
[ 7] .data PROGBITS 00000000000684b0 0005f4b0
0000000000000051 0000000000000001 AMS 0 0 16
[ 8] .data PROGBITS 0000000000068502 0005f502
0000000000000016 0000000000000002 AMS 0 0 2
[ 9] .data PROGBITS 0000000000068518 0005f518
.got inside .data is fixed by https://reviews.llvm.org/D27040, but there are still multiple .data sections.
That might be a problem and might be not. It is unclear now if EFI firmware
accepts file with multiple data or if we can have any other problems at other points like
if objcopy fine to convert this to EFI PE format.
So I believe the behavior of this patch is:
1. Fixes bug in output (no need to produce more sections that we can and take in account flags that are unused).
2. Might be helpfull for investigation such issues like above in FreeBSD at least.
https://reviews.llvm.org/D27041
More information about the llvm-commits
mailing list