elf: Add Android-specific REL,RELA and RELR constants#875
elf: Add Android-specific REL,RELA and RELR constants#875philipc merged 1 commit intogimli-rs:mainfrom
Conversation
|
We don't usually add tests for just constants, only if you're also adding code that uses them. Normally I'd ask to add these to the readobj example, but I'm currently in the process of refactoring all the constant definitions to avoid the need for that. As a result, I may also delay merging this PR until after that lands. These constants are in the OS-specific range. What's the normal way to check for an android binary to know if we should be interpreting these as such? |
|
Sorry, I confused examples with tests. I meant examples here. Currently, if I add the constants to readobj, it doesn't change any of the existing outputs.
No worries, take your time.
Oh, that's a tough question. I don't think you can reliably do that. Lower level internals of Android don't differ that much from a regular Linux distro. Those outputs are on a binary built for regular x86_64-unknown-linux-gnu target, but if you really want to identify Android executable you could perhaps rely on what is set as the dynamic linker for binary: The same trick won't work for shared objects though. |
That's fine, there's lot of constants that are listed in readobj with but have no tests.
Thanks for the info. Let's leave that until we need it. I guess for now it's ok to treat these as if they weren't OS-specific constants. That's what LLVM seems to do. |
|
Thanks. |
For the context, RELR constants would be useful for wild-linker/wild#1805. While at it, I went further and added also REL/RELA constants.
I think a test would be useful, but I don't know how to add one. Probably dissecting real Android binary would be the best, but to test most the relocations added in this PR, even regular Linux binary would be fine.
To achieve that one needs to link using LLD and
--pack-dyn-relocs=android+relr --use-android-relr-tags, but there is a catch: to have both variants of relative relocations (RELA and RELR) at the same time you need relocations with even and odd offsets.For example, using Wild's test: