This is an archive of the discontinued LLVM Phabricator instance.

[AIX][XCOFF] Write Function descriptors and TOC base to data section
ClosedPublic

Authored by jasonliu on Nov 14 2019, 1:54 PM.

Details

Summary

This patch implements writing function descriptors and TOC base into data section,
and also add function descriptors(both csect and label) and TOC base symbols to the symbol table.

Diff Detail

Event Timeline

jasonliu created this revision.Nov 14 2019, 1:54 PM
DiggerLin added inline comments.Nov 15 2019, 7:51 AM
llvm/lib/MC/XCOFFObjectWriter.cpp
256

I am not sure whether all function description data will be group together and than put in the .data section of xcoffobjectfile? all the variable data and function description will be interleaved into data section.

As I remember, I read some document , it talk about that , we put all variables in the data section first. then function description,s final is TOC entries. Maybe I wrong.

Do we care about asserting the uniqueness of the TOC anchor somewhere?

DiggerLin added inline comments.Nov 15 2019, 8:10 AM
llvm/lib/MC/XCOFFObjectWriter.cpp
256

I prefer added CsectGroup DSCsects; for function description csect.

jasonliu marked an inline comment as done.Nov 15 2019, 1:06 PM

Do we care about asserting the uniqueness of the TOC anchor somewhere?

Sure. I will do it somewhere.

llvm/lib/MC/XCOFFObjectWriter.cpp
256

Interleaving is acceptable for XCOFF format. What it hurts is readability of the symbol table.
But I think the current implementation would naturally put all the global datas first and then function descriptor later, because we always emit global data first and then process each function.

jasonliu marked an inline comment as done.Nov 15 2019, 1:09 PM
jasonliu added inline comments.
llvm/lib/MC/XCOFFObjectWriter.cpp
256

I can add a separate CsectGroup to make the contract more explicit.

DiggerLin added inline comments.Nov 17 2019, 12:26 PM
llvm/lib/MC/XCOFFObjectWriter.cpp
256

thanks Jason for clarification.

Xiangling_L added inline comments.Nov 18 2019, 7:23 AM
llvm/lib/MC/XCOFFObjectWriter.cpp
154

I am not quite sure, but my understanding is that we only have one TOC base csect in one translation unit? If I am correct, do we want to name this TOCCsect or add a comment to specify that point? It's a little confused to see plural here.

sfertile added inline comments.Nov 18 2019, 12:19 PM
llvm/lib/MC/XCOFFObjectWriter.cpp
154

Seconded. Do you intend to map the toc entries into this csect group as well?

256

If we intend to map the toc entries into TOCCsects along side the toc base csect then its probably best to follow suit and have a separate csect group for the descriptors and make this ordering explicit. If not then we need to have lit test that explicitly check that descriptor data is mapped to after read/write data. It might be worthwhile to check said tests with LLVM_REVERSE_ITERATION enabled as well to see if that has any affect.

jasonliu updated this revision to Diff 229899.Nov 18 2019, 12:41 PM

Added separate CsectGroup to contain function descriptor csects.
Added assertion to assert uniqueness TOC base.

jasonliu marked 2 inline comments as done.Nov 18 2019, 12:46 PM
jasonliu added inline comments.
llvm/lib/MC/XCOFFObjectWriter.cpp
154

The current intend is to map toc entries into this csect group. Hence named it TOCCsects. And I put an assertion in getCsectGroup() to make sure TOC-base is unique and is the first in the group.
If later we decide it's better to separate them out. I could rename the csect.

256

I map the function descriptor to a separate csect group now.

jasonliu marked 6 inline comments as done.Nov 18 2019, 12:47 PM

I believe I addressed all the comments. Thanks.

This revision is now accepted and ready to land.Nov 18 2019, 12:53 PM