Reject invalid absolute relocations in PIE/shared links#923
Reject invalid absolute relocations in PIE/shared links#923quic-areg wants to merge 1 commit intoqualcomm:mainfrom
Conversation
64c5622 to
164156c
Compare
quic-seaswara
left a comment
There was a problem hiding this comment.
Please add tests for -z text with -shared links.
It might be helpful to add tests that will fail with -z text and not with -z notext
| // Truncated absolute relocations cannot be safely represented as dynamic | ||
| // relocations for 64-bit outputs. | ||
| if (isAbs && config().targets().is64Bits() && getSize(reloc.type()) < 64) | ||
| return reportNonPICRelocation(reloc); |
There was a problem hiding this comment.
I could not follow this. This is not a dynamic relocation if the size of the reloc < 64.
Are we creating a dynamic relocation for this ?
There was a problem hiding this comment.
The point is that we cannot emit truncated absolute relocations for pie/shared links for 64-bit outputs. We currently do, and that's what this code aims to address. See pie-abs32-64.s for a test case: lld and bfd will reject the truncated relocation while today's eld will accept it.
| return reportNonPICRelocation(reloc); | ||
| } | ||
|
|
||
| bool Relocator::checkDynamicRelocAllowed(const Relocation &reloc, |
There was a problem hiding this comment.
Instead of introducing a new function, can we change the function helper_DynRel_init to error out if we are ending up creating a dynamic relocation from read only sections ?
There was a problem hiding this comment.
I think it is easier and cleaner to keep legality decisions in a separate function.
c957003 to
77c45b1
Compare
|
0a0bafb to
f20eeaa
Compare
ELD currently permits some absolute relocations that should be rejected when producing PIE/shared objects. ELD would also allow truncated absolute relocations in 64-bit outputs. Now it correctly reports an error. With -z text, reject absolute relocations in PIE/shared links. With -z notext, split behavior by target bitness: - 32-bit targets may emit TEXTREL. - 64-bit targets error on truncated absolute dynamic relocations. Closes qualcomm#832. Signed-off-by: quic-areg <aregmi@qti.qualcomm.com>
Reject invalid absolute relocations in PIE/shared links
ELD currently permits some absolute relocations that should be rejected when producing PIE/shared objects.
ELD would also allow truncated absolute relocations in 64-bit outputs. Now it correctly reports an error.
Symbols fully resolved at link time (eg defsym) should not require a dynamic relocation.
With -z text, reject absolute relocations in PIE/shared links.
With -z notext, split behavior by target bitness:
Closes #832.