-
Notifications
You must be signed in to change notification settings - Fork 2
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
Writable .plt? #3
Comments
Looks like a bug to me. In fact our .plt section isn't writable and I don't think there is a situation where we have to make it writable but I have to double-check. It has been like that in the first version of the ABI: |
Yeah, it looks like it's just a spec bug. We should be able to remove Note that on SPARC, |
The table titled "special sections" displays the SHF_WRITE flag as being set in the ".plt" section's attributes. This looks like a documentation bug that has been present since the original ABI. The .plt doesn't need to be writable, and it would pose a security risk if it were. To my knowledge (verified with Ulrich Weigand and Andreas Krebbel), existing tools never mark the .plt writable. To fix the issue, just drop the SHF_WRITE flag from the ".plt" section's attributes.
Thanks for reporting this. Yes, this looks like a bug. |
I found other minor errors. Page 47 There's a typo: ELFDATA64MSB → ELFDATA2MSB Page 48 A symbol table entry’s st_value field is the symbol value. If ... because data symbols don't have to be aligned to a 2 byte boundary. |
Good catch, thanks!
So this is more interesting. We do align all symbols, including data symbols, to a 2 byte boundary, specifically to enable use of LARL to load symbol addresses. There are a few corner cases where a compiler will actually generate a non-2-aligned data symbol, e.g. as a result of a global variable definition using an "aligned(1)" attribute. But we've considered those cases, which are all triggered by non-standard language extensions, to not be covered by this default platform ABI, but rather extensions there as well. Therefore, we've had the ABI stating the 2-byte alignment requirement unconditionally. (Without the ABI stating the requirement, it would be difficult for a compiler to reliably use LARL to access any non-local symbol. Having to avoid LARL here would significantly pessimize generated code.) |
Ooh, I didn't know that until now. Thank you for pointing it out! Now I wonder if we should print out an error message from the linker if an R_390_*DBL relocation is applied to an odd address. It is not expected to happen, and if it happens, I guess it's almost certainly an error. |
I thought we did already, but a quick test shows that apparently we don't. But I agree this is an error and should result in a message (rather than silently dropping the low bit). @Andreas-Krebbel should this be checked by GNU ld? |
It'd be also good if the spec specifies which relocations should be checked for overflow. Other psABIs specify that. I can use my common sense to add relocation overflow checks, but that behavior should be consistent across linkers. |
Yes, I'll have a look. Might require some more changes. If I remember correctly ld is abusing the lowest order bit of the symbol address as a flag for something. Horrible, I know ;) |
Thanks! Commit dcfabd8 has just been pushed to fix this typo. |
I've posted a patch to issue an error for *DBL relocs on misaligned symbols: |
On page 33, .plt is defined as
SHT_PROGBITS
with attributes ofSHF_ALLOC + SHF_WRITE + SHF_EXECINSTR
. If we just follow the words, it ends up with a writable code segment. Shouldn't we drop+ SHF_WRITE
?The text was updated successfully, but these errors were encountered: