@@ -3816,10 +3816,12 @@ void GNUELFDumper<ELFT>::printRelRelaReloc(const Relocation<ELFT> &R,
3816
3816
}
3817
3817
3818
3818
template <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) {
3820
3821
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);
3823
3825
if (ELFT::Is64Bits)
3824
3826
OS << " ";
3825
3827
else
@@ -3844,16 +3846,18 @@ void GNUELFDumper<ELFT>::printDynamicRelocHeader(unsigned Type, StringRef Name,
3844
3846
uint64_t Offset = Reg.Addr - this->Obj.base();
3845
3847
OS << "\n'" << Name.str().c_str() << "' relocation section at offset 0x"
3846
3848
<< utohexstr(Offset, /*LowerCase=*/true) << " contains " << Reg.Size << " bytes:\n";
3847
- printRelocHeaderFields<ELFT>(OS, Type);
3849
+ printRelocHeaderFields<ELFT>(OS, Type, this->Obj.getHeader() );
3848
3850
}
3849
3851
3850
3852
template <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) {
3852
3855
return Sec.sh_type == ELF::SHT_REL || Sec.sh_type == ELF::SHT_RELA ||
3853
3856
Sec.sh_type == ELF::SHT_RELR || Sec.sh_type == ELF::SHT_ANDROID_REL ||
3854
3857
Sec.sh_type == ELF::SHT_ANDROID_RELA ||
3855
3858
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);
3857
3861
}
3858
3862
3859
3863
template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
@@ -3871,7 +3875,8 @@ template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
3871
3875
3872
3876
if (!opts::RawRelr &&
3873
3877
(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))) {
3875
3880
Expected<Elf_Relr_Range> RelrsOrErr = this->Obj.relrs(Sec);
3876
3881
if (!RelrsOrErr)
3877
3882
return RelrsOrErr.takeError();
@@ -3883,7 +3888,7 @@ template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
3883
3888
3884
3889
bool HasRelocSections = false;
3885
3890
for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
3886
- if (!isRelocationSec<ELFT>(Sec))
3891
+ if (!isRelocationSec<ELFT>(Sec, this->Obj.getHeader() ))
3887
3892
continue;
3888
3893
HasRelocSections = true;
3889
3894
@@ -3900,7 +3905,7 @@ template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
3900
3905
OS << "\nRelocation section '" << Name << "' at offset 0x"
3901
3906
<< utohexstr(Offset, /*LowerCase=*/true) << " contains " << EntriesNum
3902
3907
<< " entries:\n";
3903
- printRelocHeaderFields<ELFT>(OS, Sec.sh_type);
3908
+ printRelocHeaderFields<ELFT>(OS, Sec.sh_type, this->Obj.getHeader() );
3904
3909
this->printRelocationsHelper(Sec);
3905
3910
}
3906
3911
if (!HasRelocSections)
@@ -6235,7 +6240,8 @@ void ELFDumper<ELFT>::forEachRelocationDo(
6235
6240
// sh_link field as an index of a symbol table.
6236
6241
const Elf_Shdr *SymTab;
6237
6242
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)) {
6239
6245
Expected<const Elf_Shdr *> SymTabOrErr = Obj.getSection(Sec.sh_link);
6240
6246
if (!SymTabOrErr) {
6241
6247
Warn(SymTabOrErr.takeError(), "unable to locate a symbol table for");
@@ -6264,11 +6270,8 @@ void ELFDumper<ELFT>::forEachRelocationDo(
6264
6270
}
6265
6271
break;
6266
6272
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)
6270
6274
break;
6271
- }
6272
6275
[[fallthrough]];
6273
6276
case ELF::SHT_RELR:
6274
6277
case ELF::SHT_ANDROID_RELR: {
@@ -6966,7 +6969,7 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printRelocations() {
6966
6969
ListScope D(W, "Relocations");
6967
6970
6968
6971
for (const Elf_Shdr &Sec : cantFail(this->Obj.sections())) {
6969
- if (!isRelocationSec<ELFT>(Sec))
6972
+ if (!isRelocationSec<ELFT>(Sec, this->Obj.getHeader() ))
6970
6973
continue;
6971
6974
6972
6975
StringRef Name = this->getPrintableSectionName(Sec);
0 commit comments