Stringify an offset

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



When implementing shims and executable blob for various confidential
computing platforms like Intel SGX, AMD SEV-SNP and probably also upcoming
ARMv9 REALMS, you often need to markup segments so that the loader knows to
do how to do the "right thing".

For instance, SGX has so called Thread Control Structure (TCS) pages, which
are essentially entry points to the "enclaves", which is just a fancy name
for executable blobs. TCS pages are contained within the enclave address
space but need to be initialized in a special manner, so you need to hint
the loader, which data segments contain them.

Two ways that I know how to do that are both somewhat ugly hacks:

1. Use spare flags in p_flags.
2. Create a PT_NOTE with a name "TCS" and use p_descz to describe an
   offset. This is limits of course to 32-bit offset unless you pick
   from these to bad malwareish choices:
   a. Overwrite p_type with the other part of the address.
   b. Use two PT_NOTE entries for high and low parts of the address.

I came up with solution that should be technically possible to implement in
GCC that would scale all these needs and would not need anything
substantially huge.

I would be like to be able to do PT_NOTE's with a name formatted as
follows:

   TCSxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

Here x's represent zero padded hexadecimal offset of a label. Does GAS
provide as of today something to "stringify" a label into address? If not,
would that be something that could be added to GAS and GCC, or if it was
contributed, would it be considered for upstream?

There's dozens of similar cases in these technologies where this would
solve the problem, so a solution that *specifically* sorts it out just
for these TCS pages is not adequate. It was just one example.

BR, Jarkko



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux