This is an archive of the discontinued LLVM Phabricator instance.

[ELF][AArch64] Improve error message for unknown relocations
ClosedPublic

Authored by MaskRay on Aug 14 2019, 10:40 PM.

Details

Summary

Like rLLD354040.

Previously, for unrecognized relocation types, in -no-pie/-pie mode, we got something like:

foo.o: unrecognized relocation ...

In -shared mode:

error: can't create dynamic relocation ... against symbol: yyy in readonly segment

Event Timeline

MaskRay created this revision.Aug 14 2019, 10:40 PM

How about adding a test case? See test\ELF\invalid\invalid-relocation-x64.test for example.

Looks good to me. George's suggestion for a test is a good one. From a brief look some of the other targets also return R_ABS by default from getRelExpr, such as ARM, PPC, PPC64, Hexagon, MSP430, AVR. I don't think it is worth applying this method universally to all of them, but it may be worth ARM, PPC and PPC64. When this goes in I'd be happy to submit a similar patch for ARM.

MaskRay updated this revision to Diff 215350.Aug 15 2019, 2:36 AM

Add ELF\invalid\invalid-relocation-aarch64.test

MaskRay updated this revision to Diff 215356.Aug 15 2019, 2:43 AM
MaskRay edited the summary of this revision. (Show Details)

Clarify.

error: can't create dynamic relocation ... against symbol:

was in -shared mode

grimar accepted this revision.Aug 15 2019, 2:49 AM

LGTM. 2 nits are below.

test/ELF/invalid/invalid-relocation-aarch64.test
4

Why do you need --defsym=foo=0?

12

I think you do not need "OSABI".

This revision is now accepted and ready to land.Aug 15 2019, 2:49 AM
MaskRay updated this revision to Diff 215359.Aug 15 2019, 2:59 AM
MaskRay marked 2 inline comments as done.

Delete OSABI

Add Section: .text and delete --defsym=foo=0

This revision was automatically updated to reflect the committed changes.