This is an archive of the discontinued LLVM Phabricator instance.

Error instead of producing broken binary
ClosedPublic

Authored by espindola on Mar 12 2018, 9:59 PM.

Details

Reviewers
ruiu
emaste
grimar
Summary

This "fixes" PR36678 by just producing an error when we find a case where we would produce an plt entry that used ebx but ebx would not be set.

Diff Detail

Event Timeline

espindola created this revision.Mar 12 2018, 9:59 PM
grimar added a subscriber: grimar.Mar 14 2018, 1:35 AM
grimar added inline comments.
ELF/Arch/X86.cpp
68 ↗(On Diff #138128)

a library

70 ↗(On Diff #138128)

Comment saying "for PIE", but Config->Pic also covers DSO, we have Config->Pie for PIE. Is this if correct?
We will report "cannot be used against symbol" for -shared case, so I think it can be if (Config->Pie).

George Rimar via Phabricator via llvm-commits
<llvm-commits@lists.llvm.org> writes:

grimar added inline comments.

Comment at: ELF/Arch/X86.cpp:68
+ compiled without -fPIE/-fPIC and doesn't maintain ebx.
+
* If a libray definition gets preempted to the executable, it will have the

+ // wrong ebx value.

a library

Thanks.

Comment at: ELF/Arch/X86.cpp:70
+ // wrong ebx value.
+ if (Config->Pic)

+ SupportsPltPreemption = false;

Comment saying "for PIE", but Config->Pic also covers DSO, we have Config->Pie for PIE. Is this if correct?
We will report "cannot be used against symbol" for -shared case, so I think it can be if (Config->Pie).

They would be equivalent as the canonical plt hack never works for
shared libraries, but using Pie is definitely better.

I will upload a new version.

Thanks,
Rafael

espindola added a reviewer: grimar.
ruiu added inline comments.Mar 14 2018, 10:23 AM
ELF/Relocations.cpp
878

I wouldn't generalize this as a Target member because I believe you need it only for i386. Even if there are two or more targets that need this, you could generalize when you add another arch.

879–880

Please add a hint to the error message about how to fix the problem. You could fix this by recompiling with -fPIC, right?

ruiu accepted this revision.Mar 14 2018, 10:50 AM

LGTM

This revision is now accepted and ready to land.Mar 14 2018, 10:50 AM