PPC64 has several special sections that are intended to be accessed from the TOC base pointer. When a .got is present, the TOC base pointer is .got + 0x8000 (as specified by the ABI). Furthermore, the glibc startup code contains an assumption that a 16-bit relocation can hold the offset from the TOC base value to the beginning of the .toc section. Thus, we need to make sure that .toc appears after .got. This much, at least, is required in practice. The other PPC64 special sections (.toc, .toc1, .opd, etc.) should also be close by to optimize access by smaller TOC-base-pointer offsets.
Diff Detail
Event Timeline
ELF/Writer.cpp | ||
---|---|---|
361–365 | You can simplify this by defining a function, say getPPCRank(StringRef), which returns an integer value according to this table. 0 .tocbss 1 any other name 2 .toc 3 .branch_lt 4 .toc 5 .toc1 6 .opd Then you can use that function in this function like this return getPPCRank(A) < getPPCRank(B); |
ELF/Writer.cpp | ||
---|---|---|
311–317 | Sorry, I meant 0 .tocbss 1 any other name 2 .got (* was a typo) 3 .branch_lt 4 .toc 5 .toc1 6 .opd This is my interpretation of your code. I'm not 100% sure that this ranking is correct, though. So please verify. Also please remove excessive spaces at .Case("...", <*here*><number>) |
ELF/Writer.cpp | ||
---|---|---|
311–317 | I know, but if I do that, then I'll change the order of .got relative to other like sections for all targets. Is that okay? |
ELF/Writer.cpp | ||
---|---|---|
311–317 | If you don't need that for PPC now, you can leave .got as is. |
ELF/Writer.cpp | ||
---|---|---|
311–317 | Okay; I'll leave it like this for now. It is okay for my current test cases, and I'm happy to deal with future enhancements if/when they become necessary. |
Sorry, I meant
This is my interpretation of your code. I'm not 100% sure that this ranking is correct, though. So please verify.
Also please remove excessive spaces at .Case("...", <*here*><number>)