-
Notifications
You must be signed in to change notification settings - Fork 55
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
Can TD-Shim skip relocations for the ELF payload? #420
Comments
td-shim relocates the payload at runtime unconditionally. We can add a feature flag to disable the relocation at runtime |
@gaojiaqi7 Thanks for reply. Yes, adding such a flag would be nice. |
Thanks @gaojiaqi7! I'll try this PR tomorrow. |
@gaojiaqi7 Got this error after updating to your #424 branch:
Note that I didn't yet apply the |
I can't reproduce this error with the example |
Ok, a clean rebuild fixed this issue. My payload works fine without the But when I tried I have a stupid question: where do I need to add this feature? Here's roughly how I tested:
Is this sequence correct? |
Yes, it is correct. The feature is set to td-shim |
@dimakuv how does your ELF payload read its own ELF header and metadata, using offset or something else? Dose the payload needs loader to map its segments to the specified virtual address? |
@gaojiaqi7 The ELF payload reads its own ELF header and metadata using a global symbol that is located at the very start of the ELF file image (and thus points to the ELF header). Similar to this code:
There is no need for the loader to map the segments to the specific virtual address. The address can be anything. |
Hi @dimakuv I updated the branch today, can you try again with the latest? |
@gaojiaqi7 No, still the same problem. And I still didn't have time to debug it fully. |
I am developing my ELF payload that TD-Shim loads.
My ELF payload is a generic OS kernel that can be started in different ways. One of these ways is as an ELF payload via the TD-Shim.
Therefore, my ELF payload has a generic startup sequence that has the step of self-relocation. In other words, one of the first things my ELF payload does is to find all relocations (by reading its own ELF header and metadata) and apply them.
I am confused by the TD-Shim linker logic:
On the one hand,
td-shim-ld
has an option--relocate-payload
. So I skip this option, which should meanrelocate-payload = false
and thusself.payload_relocation == false
, which should not perform any relocations in my ELF payload:td-shim/td-shim-tools/src/linker.rs
Lines 413 to 425 in 553e3e6
On the other hand,
td-shim-ld
seems to relocate the ELF payload anyway, disregarding the value of--relocate-payload
:td-shim/td-shim-tools/src/linker.rs
Lines 437 to 444 in 553e3e6
Maybe I don't understand the difference between
payload
andipl
? Is there a way to skip relocations of my ELF payload?The text was updated successfully, but these errors were encountered: