[lld] r292359 - [ELF] Move createThunks() after scanRelocations()
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Fri Jan 20 07:15:11 PST 2017
LGTM, thanks!
Peter Smith <peter.smith at linaro.org> writes:
> Yes you are right, I missed that scanRelocs() would have already
> stored the result of getThunkExpr() in Rel.Expr. Thanks for the
> suggestion.
>
> I've updated the patch and removed Type = Rel.Type and Body = *Rel.Sym
> in favour of using them directly in the call to addThunk.
>
> Let me know if that's ok to commit or if you want any more changes?
>
> Peter
>
> On 19 January 2017 at 20:37, Rafael Avila de Espindola
> <rafael.espindola at gmail.com> wrote:
>> Peter Smith <peter.smith at linaro.org> writes:
>>> + RelExpr Expr = Rel.Expr;
>>> + Expr = Target->getThunkExpr(Expr, Type, IS->getFile(), Body);
>>
>> You can delete the call to getThunkExpr too, no?
>>
>> Cheers,
>> Rafael
> From 6091f1ac85161deb88a06349840b6a03c8e9d345 Mon Sep 17 00:00:00 2001
> From: Peter Smith <peter.smith at linaro.org>
> Date: Thu, 19 Jan 2017 14:32:51 +0000
> Subject: [PATCH] [ELF] Cleanup createThunks() NFC.
>
> Include removal of call to getThunkExpr() as it has already been
> called and recorded by scanRelocs()
>
> Cleanup suggestions by Rafael.
> ---
> ELF/Relocations.cpp | 33 ++++++++++++++-------------------
> 1 file changed, 14 insertions(+), 19 deletions(-)
>
> diff --git a/ELF/Relocations.cpp b/ELF/Relocations.cpp
> index 1f33954..a57996f 100644
> --- a/ELF/Relocations.cpp
> +++ b/ELF/Relocations.cpp
> @@ -808,25 +808,20 @@ template <class ELFT> void scanRelocations(InputSectionBase<ELFT> &S) {
> template <class ELFT>
> void createThunks(ArrayRef<OutputSectionBase *> OutputSections) {
> for (OutputSectionBase *Base : OutputSections) {
> - if (auto *OS = dyn_cast<OutputSection<ELFT>>(Base)) {
> - for (InputSection<ELFT> *IS : OS->Sections) {
> - for (const Relocation &Rel : IS->Relocations) {
> - if (Rel.Sym == nullptr) {
> - continue;
> - }
> - SymbolBody &Body = *Rel.Sym;
> - uint32_t Type = Rel.Type;
> - RelExpr Expr = Rel.Expr;
> - if (!isPreemptible(Body, Type) && needsPlt(Expr))
> - Expr = fromPlt(Expr);
> - Expr = Target->getThunkExpr(Expr, Type, IS->getFile(), Body);
> - // Some targets might require creation of thunks for relocations.
> - // Now we support only MIPS which requires LA25 thunk to call PIC
> - // code from non-PIC one, and ARM which requires interworking.
> - if (Expr == R_THUNK_ABS || Expr == R_THUNK_PC ||
> - Expr == R_THUNK_PLT_PC)
> - addThunk<ELFT>(Type, Body, *IS);
> - }
> + auto *OS = dyn_cast<OutputSection<ELFT>>(Base);
> + if (OS == nullptr)
> + continue;
> + for (InputSection<ELFT> *IS : OS->Sections) {
> + for (const Relocation &Rel : IS->Relocations) {
> + if (Rel.Sym == nullptr)
> + continue;
> + RelExpr Expr = Rel.Expr;
> + // Some targets might require creation of thunks for relocations.
> + // Now we support only MIPS which requires LA25 thunk to call PIC
> + // code from non-PIC one, and ARM which requires interworking.
> + if (Expr == R_THUNK_ABS || Expr == R_THUNK_PC ||
> + Expr == R_THUNK_PLT_PC)
> + addThunk<ELFT>(Rel.Type, *Rel.Sym, *IS);
> }
> }
> }
> --
> 2.7.4
More information about the llvm-commits
mailing list