ELF: reloc section names
sunfishcode opened this issue · 1 comments
Using faerie through llvm2cretonne on this:
declare void @foo()
define void @bar() {
call void @foo()
ret void
}
I get an object file with a section named ".reloc.bar" (and the string table contains an entry for ".reloc.text.bar" as well as ".reloc.bar"). The SysV ABI says that reloc sections should be named ".relaname" (or ".relname" for non-RELA), which in this case would be ".rela.text.bar".
I took a look at fixing this; changing ".reloc" to ".rela" is easy, but it doesn't look like the original reloc section string is saved anywhere, and I didn't see a way for add_reloc
to know if it should add ".text." or ".data." to recreate the name.
This isn't urgent, as it seems like most tools don't care about the name (which makes sense, because they're supposed to use the sh_type
and sh_info
fields instead of the name), but it is a difference from what other ELF writers emit.
I’m going to be pedantic and quote:
Conventionally, name is supplied by the section to which the relocations apply.
Emphasis mine. This does not seem normative to me, but as the emphasis suggests, a convention.
I would have to check, but I would be shocked that sections aren’t normatively relocated via sh_link and friends as you describe.
Consequently, I don’t think we have to change it.
Nevertheless, I am completely ok with matching “typical output” of other object file writers (in fact that’s how I wrote both the ELF and macho backends primarily), and I’ll merge anything that does this (within reason)
Since for now, as this doesn’t affect anything afaics, i personally probably won’t try to fix this, as id prefer to add an archive backend, and/ or refactor the elf backend to be cleaner, and of course, get different architecture relocations working, but as I said I’ll merge anything that does fix it :)