Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOLT]How to add a Global Symbol in BOLT Pass #121322

Open
wuwen03 opened this issue Dec 30, 2024 · 0 comments
Open

[BOLT]How to add a Global Symbol in BOLT Pass #121322

wuwen03 opened this issue Dec 30, 2024 · 0 comments
Labels
BOLT question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

Comments

@wuwen03
Copy link

wuwen03 commented Dec 30, 2024

When writing a BOLT Pass, I have to add some data in data section and create a Symbol which references the data. Then I will use the Symbol to generate some MCInst. I code it as bellow:

        uint8_t *array = new uint8_t [1024];
        auto &Section = BC.registerOrUpdateSection("MyData", ELF::SHT_PROGBITS, BinarySection::getFlags(false,false,true),array,1024);
        array[0] = 1;//generate some data in the Section
        Section.setOutputAddress(/*I don't know*/);
        Section.setOutputFileOffset(/*"I don't know"*/);
        int SymbolAddress;/*I don't know*/
        BC.getOrCreateGlobalSymbol(SymbolAddress, "DATAAt",8);

However, the Symbol must be given a specific Address which is corresponding to the Section OutputAddress. However, the OutputAddress and OutputFileOffset is defined after all the BOLT PASSes, so I can't get the information inside my BOLT PASS, and I failed to define them by myself.
Is there any way to handle it?

@github-actions github-actions bot added the BOLT label Dec 30, 2024
@EugeneZelenko EugeneZelenko added the question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead! label Dec 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BOLT question A question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!
Projects
None yet
Development

No branches or pull requests

2 participants