[llvm] 1d32143 - [llvm-xray] Add AArch64 to llvm-xray extract

Aditya K via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 8 18:32:49 PST 2019


@smeenai  added tests here: https://reviews.llvm.org/rG56cd447eec8eec71a6e61d2dd142bf5dadfc154a



--


From: Roman Lebedev <lebedev.ri at gmail.com>

Sent: Friday, November 8, 2019 1:58 PM

To: Aditya K <hiraditya at msn.com>

Cc: Aditya Kumar <llvmlistbot at llvm.org>; llvm-commits at lists.llvm.org <llvm-commits at lists.llvm.org>

Subject: Re: [llvm] 1d32143 - [llvm-xray] Add AArch64 to llvm-xray extract

 


No problem, thanks.



On Fri, Nov 8, 2019 at 10:57 PM Aditya K <hiraditya at msn.com> wrote:

>

> oh, I must have missed it. I'll add them tonight when I'm back on my home computer where i have the commit access.

> Sorry about that.

>

> -Aditya

>

>

>

>

> From: Roman Lebedev <lebedev.ri at gmail.com>

>

> Sent: Friday, November 8, 2019 8:40 AM

>

> To: Aditya Kumar <hiraditya at msn.com>; Aditya Kumar <llvmlistbot at llvm.org>

>

> Cc: llvm-commits at lists.llvm.org <llvm-commits at lists.llvm.org>

>

> Subject: Re: [llvm] 1d32143 - [llvm-xray] Add AArch64 to llvm-xray extract

>

>

>

>

> Where did the test coverage go?

>

>

>

> On Fri, Nov 8, 2019 at 5:38 PM Aditya Kumar via llvm-commits

>

> <llvm-commits at lists.llvm.org> wrote:

>

> >

>

> >

>

> > Author: Aditya Kumar

>

> > Date: 2019-11-08T06:37:47-08:00

>

> > New Revision: 1d321434a202b12b3afe6f305262b930bbf05665

>

> >

>

> > URL:

> 
https://github.com/llvm/llvm-project/commit/1d321434a202b12b3afe6f305262b930bbf05665

>

> > DIFF:

> 
https://github.com/llvm/llvm-project/commit/1d321434a202b12b3afe6f305262b930bbf05665.diff

>

> >

>

> > LOG: [llvm-xray] Add AArch64 to llvm-xray extract

>

> >

>

> > This required adding support for resolving R_AARCH64_ABS64 relocations to

>

> > get accurate addresses for function names to resolve.

>

> >

>

> > Authored by: ianlevesque (Ian Levesque)

>

> > Reviewers: dberris, phosek, smeenai, tetsuo-cpp

>

> > Differential Revision: https://reviews.llvm.org/D69967

>

> >

>

> > Added:

>

> >

>

> >

>

> > Modified:

>

> >     llvm/lib/XRay/InstrumentationMap.cpp

>

> >

>

> > Removed:

>

> >

>

> >

>

> >

>

> > ################################################################################

>

> > diff  --git a/llvm/lib/XRay/InstrumentationMap.cpp b/llvm/lib/XRay/InstrumentationMap.cpp

>

> > index 7453613c7038..1e9b69a5f9dc 100644

>

> > --- a/llvm/lib/XRay/InstrumentationMap.cpp

>

> > +++ b/llvm/lib/XRay/InstrumentationMap.cpp

>

> > @@ -20,6 +20,7 @@

>

> >  #include "llvm/Object/Binary.h"

>

> >  #include "llvm/Object/ELFObjectFile.h"

>

> >  #include "llvm/Object/ObjectFile.h"

>

> > +#include "llvm/Object/RelocationResolver.h"

>

> >  #include "llvm/Support/DataExtractor.h"

>

> >  #include "llvm/Support/Error.h"

>

> >  #include "llvm/Support/FileSystem.h"

>

> > @@ -59,7 +60,8 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,

>

> >    // Find the section named "xray_instr_map".

>

> >    if ((!ObjFile.getBinary()->isELF() && !ObjFile.getBinary()->isMachO()) ||

>

> >        !(ObjFile.getBinary()->getArch() == Triple::x86_64 ||

>

> > -        ObjFile.getBinary()->getArch() == Triple::ppc64le))

>

> > +        ObjFile.getBinary()->getArch() == Triple::ppc64le ||

>

> > +        ObjFile.getBinary()->getArch() == Triple::aarch64))

>

> >      return make_error<StringError>(

>

> >          "File format not supported (only does ELF and Mach-O little endian 64-bit).",

>

> >          std::make_error_code(std::errc::not_supported));

>

> > @@ -99,12 +101,22 @@ loadObj(StringRef Filename, object::OwningBinary<object::ObjectFile> &ObjFile,

>

> >          return static_cast<uint32_t>(0);

>

> >      }(ObjFile.getBinary());

>

> >

>

> > +    bool (*SupportsRelocation)(uint64_t);

>

> > +    object::RelocationResolver Resolver;

>

> > +    std::tie(SupportsRelocation, Resolver) =

>

> > +        object::getRelocationResolver(*ObjFile.getBinary());

>

> > +

>

> >      for (const object::SectionRef &Section : Sections) {

>

> >        for (const object::RelocationRef &Reloc : Section.relocations()) {

>

> > -        if (Reloc.getType() != RelativeRelocation)

>

> > -          continue;

>

> > -        if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend())

>

> > -          Relocs.insert({Reloc.getOffset(), *AddendOrErr});

>

> > +        if (SupportsRelocation && SupportsRelocation(Reloc.getType())) {

>

> > +          auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend();

>

> > +          auto A = AddendOrErr ? *AddendOrErr : 0;

>

> > +          uint64_t resolved = Resolver(Reloc, Reloc.getSymbol()->getValue(), A);

>

> > +          Relocs.insert({Reloc.getOffset(), resolved});

>

> > +        } else if (Reloc.getType() == RelativeRelocation) {

>

> > +          if (auto AddendOrErr = object::ELFRelocationRef(Reloc).getAddend())

>

> > +            Relocs.insert({Reloc.getOffset(), *AddendOrErr});

>

> > +        }

>

> >        }

>

> >      }

>

> >    }

>

> >

>

> >

>

> >

>

> > _______________________________________________

>

> > llvm-commits mailing list

>

> > llvm-commits at lists.llvm.org

>

> > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits

>



More information about the llvm-commits mailing list