DescriptionPNaCl dynamic linking: Fix handling of local relocations with addends
While testing ConvertToPSO on newlib's libc.a, I found that the pass
didn't work on relocations with addends that refer to module-local
variables.
The reason is that we're running FlattenGlobals twice (once in
"-convert-to-pso" and once in "-pnacl-abi-simplify-postopt"), but
FlattenGlobals isn't idempotent for this case. FlattenGlobals can
handle a getelementptr as input, but it converts it to ptrtoint+add,
which it doesn't handle.
Fix this by changing FlattenGlobals to handle "add" ConstantExprs.
Testing:
* convert-to-pso.ll: Test this end-to-end.
* flatten-globals.ll: Check this specific case, and check idempotence
in general.
The latter requires that we use getSExtValue() (sign-extending)
rather than getZExtValue() (zero-extending), otherwise the
negative-addend test fails with "FlattenGlobals: Offset does not
fit into 32 bits".
BUG=https://bugs.chromium.org/p/nativeclient/issues/detail?id=4351
TEST=test/Transforms/NaCl/*.ll
R=phosek@chromium.org
Committed: https://chromium.googlesource.com/native_client/pnacl-llvm/+/aa09f2c4ce3ced974ef25e004106345daaaebd04
Patch Set 1 #
Messages
Total messages: 6 (3 generated)
|