@@ -3816,10 +3816,12 @@ void GNUELFDumper<ELFT>::printRelRelaReloc(const Relocation<ELFT> &R,
38163816}
38173817
38183818template <class ELFT >
3819- static void printRelocHeaderFields (formatted_raw_ostream &OS, unsigned SType) {
3819+ static void printRelocHeaderFields (formatted_raw_ostream &OS, unsigned SType,
3820+ const typename ELFT::Ehdr &EHeader) {
38203821 bool IsRela = SType == ELF::SHT_RELA || SType == ELF::SHT_ANDROID_RELA;
3821- bool IsRelr = SType == ELF::SHT_RELR || SType == ELF::SHT_ANDROID_RELR ||
3822- SType == ELF::SHT_AARCH64_AUTH_RELR;
3822+ bool IsRelr =
3823+ SType == ELF::SHT_RELR || SType == ELF::SHT_ANDROID_RELR ||
3824+ (EHeader.e_machine == EM_AARCH64 && SType == ELF::SHT_AARCH64_AUTH_RELR);
38233825 if (ELFT::Is64Bits)
38243826 OS << " " ;
38253827 else
@@ -3844,16 +3846,18 @@ void GNUELFDumper<ELFT>::printDynamicRelocHeader(unsigned Type, StringRef Name,
38443846 uint64_t Offset = Reg.Addr - this ->Obj .base ();
38453847 OS << " \n '" << Name.str ().c_str () << " ' relocation section at offset 0x"
38463848 << utohexstr (Offset, /* LowerCase=*/ true ) << " contains " << Reg.Size << " bytes:\n " ;
3847- printRelocHeaderFields<ELFT>(OS, Type);
3849+ printRelocHeaderFields<ELFT>(OS, Type, this -> Obj . getHeader () );
38483850}
38493851
38503852template <class ELFT >
3851- static bool isRelocationSec (const typename ELFT::Shdr &Sec) {
3853+ static bool isRelocationSec (const typename ELFT::Shdr &Sec,
3854+ const typename ELFT::Ehdr &EHeader) {
38523855 return Sec.sh_type == ELF::SHT_REL || Sec.sh_type == ELF::SHT_RELA ||
38533856 Sec.sh_type == ELF::SHT_RELR || Sec.sh_type == ELF::SHT_ANDROID_REL ||
38543857 Sec.sh_type == ELF::SHT_ANDROID_RELA ||
38553858 Sec.sh_type == ELF::SHT_ANDROID_RELR ||
3856- Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR;
3859+ (EHeader.e_machine == EM_AARCH64 &&
3860+ Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR);
38573861}
38583862
38593863template <class ELFT > void GNUELFDumper<ELFT>::printRelocations() {
@@ -3871,7 +3875,8 @@ template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
38713875
38723876 if (!opts::RawRelr &&
38733877 (Sec.sh_type == ELF::SHT_RELR || Sec.sh_type == ELF::SHT_ANDROID_RELR ||
3874- Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR)) {
3878+ (this ->Obj .getHeader ().e_machine == EM_AARCH64 &&
3879+ Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR))) {
38753880 Expected<Elf_Relr_Range> RelrsOrErr = this ->Obj .relrs (Sec);
38763881 if (!RelrsOrErr)
38773882 return RelrsOrErr.takeError ();
@@ -3883,7 +3888,7 @@ template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
38833888
38843889 bool HasRelocSections = false ;
38853890 for (const Elf_Shdr &Sec : cantFail (this ->Obj .sections ())) {
3886- if (!isRelocationSec<ELFT>(Sec))
3891+ if (!isRelocationSec<ELFT>(Sec, this -> Obj . getHeader () ))
38873892 continue ;
38883893 HasRelocSections = true ;
38893894
@@ -3900,7 +3905,7 @@ template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
39003905 OS << " \n Relocation section '" << Name << " ' at offset 0x"
39013906 << utohexstr (Offset, /* LowerCase=*/ true ) << " contains " << EntriesNum
39023907 << " entries:\n " ;
3903- printRelocHeaderFields<ELFT>(OS, Sec.sh_type );
3908+ printRelocHeaderFields<ELFT>(OS, Sec.sh_type , this -> Obj . getHeader () );
39043909 this ->printRelocationsHelper (Sec);
39053910 }
39063911 if (!HasRelocSections)
@@ -6235,7 +6240,8 @@ void ELFDumper<ELFT>::forEachRelocationDo(
62356240 // sh_link field as an index of a symbol table.
62366241 const Elf_Shdr *SymTab;
62376242 if (Sec.sh_type != ELF::SHT_RELR && Sec.sh_type != ELF::SHT_ANDROID_RELR &&
6238- Sec.sh_type != ELF::SHT_AARCH64_AUTH_RELR) {
6243+ !(Obj.getHeader ().e_machine == EM_AARCH64 &&
6244+ Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR)) {
62396245 Expected<const Elf_Shdr *> SymTabOrErr = Obj.getSection (Sec.sh_link );
62406246 if (!SymTabOrErr) {
62416247 Warn (SymTabOrErr.takeError (), " unable to locate a symbol table for" );
@@ -6264,11 +6270,8 @@ void ELFDumper<ELFT>::forEachRelocationDo(
62646270 }
62656271 break ;
62666272 case ELF::SHT_AARCH64_AUTH_RELR:
6267- if (Obj.getHeader ().e_machine != EM_AARCH64) {
6268- this ->reportUniqueWarning (
6269- " SHT_AARCH64_AUTH_RELR section in non-AArch64 ELF found, skipping" );
6273+ if (Obj.getHeader ().e_machine != EM_AARCH64)
62706274 break ;
6271- }
62726275 [[fallthrough]];
62736276 case ELF::SHT_RELR:
62746277 case ELF::SHT_ANDROID_RELR: {
@@ -6966,7 +6969,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printRelocations() {
69666969 ListScope D (W, " Relocations" );
69676970
69686971 for (const Elf_Shdr &Sec : cantFail (this ->Obj .sections ())) {
6969- if (!isRelocationSec<ELFT>(Sec))
6972+ if (!isRelocationSec<ELFT>(Sec, this -> Obj . getHeader () ))
69706973 continue ;
69716974
69726975 StringRef Name = this ->getPrintableSectionName (Sec);
0 commit comments