[PATCH] D68101: [MC][ELF] Prevent globals with an explicit section from being mergeable
Sjoerd Meijer via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Oct 1 02:58:34 PDT 2019
SjoerdMeijer added a comment.
I am getting up to speed with this... and created this reproducer:
static int A[4] __attribute__ ((section ("HELLO"))) = {1,0,0,1} ;
static long long B[9] __attribute__ ((section ("HELLO"))) = {0,0,0,0,0,0,0,0,1};
int foo (int i) {
return A[i] + B[i];
}
The corresponding ELF object contains this section:
Name : HELLO
Type : SHT_PROGBITS (0x00000001)
Flags : SHF_ALLOC + SHF_MERGE (0x00000012)
Addr : 0x00000000
File Offset : 96 (0x60)
Size : 88 bytes (0x58)
Link : SHN_UNDEF
Info : 0
Alignment : 8
Entry Size : 16
You're unhappy about the `Entry Size : 16`, as this sections contains entries of words and double-words. The ELF spec says this about this entry:
The size of each element is specified in the section header's sh_entsize field.
So yes, I guess that means the entry size needs to be uniform.
Now my question about this patch: why are we trying to patch things up when we can avoid putting incompatible symbols in the same section in the first place? In this case, the merging is achieved with a section attribute, but from the PR I understood the same can be achieved with a pragma, so from that point of view we perhaps got what we deserved? Would be nice though to warn about this, and/or the pass that does the merging should not do this?
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D68101/new/
https://reviews.llvm.org/D68101
More information about the llvm-commits
mailing list