Skip to content

Commit 89c95ef

Browse files
authored
[llvm-readobj] Remove --raw-relr
https://reviews.llvm.org/D47919 dumped RELR relocations as `R_*_RELATIVE` and added --raw-relr (not in GNU) for testing purposes (more readable than `llvm-readelf -x .relr.dyn`). The option is obsolete after `llvm-readelf -r` output gets improved (llvm#89162). Since --raw-relr never seems to get more adoption. Let's remove it to avoid some complexity. Pull Request: llvm#89426
1 parent a6f1b3a commit 89c95ef

File tree

8 files changed

+21
-112
lines changed

8 files changed

+21
-112
lines changed

llvm/docs/CommandGuide/llvm-readelf.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ OPTIONS
152152

153153
Display the program headers.
154154

155-
.. option:: --raw-relr
156-
157-
Do not decode relocations in RELR relocation sections when displaying them.
158-
159155
.. option:: --relocations, --relocs, -r
160156

161157
Display the relocation entries in the file.

llvm/docs/CommandGuide/llvm-readobj.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,10 +255,6 @@ The following options are implemented only for the ELF file format.
255255

256256
Display the program headers.
257257

258-
.. option:: --raw-relr
259-
260-
Do not decode relocations in RELR relocation sections when displaying them.
261-
262258
.. option:: --section-mapping
263259

264260
Display the section to segment mapping.

llvm/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,10 @@ Changes to the LLVM tools
198198
documentation for SPGO
199199
<https://clang.llvm.org/docs/UsersManual.html#using-sampling-profilers>`_.
200200

201+
* llvm-readelf's ``-r`` output for RELR has been improved.
202+
(`#89162 <https://github.com/llvm/llvm-project/pull/89162>`_)
203+
``--raw-relr`` has been removed.
204+
201205
Changes to LLDB
202206
---------------------------------
203207

llvm/test/tools/llvm-readobj/ELF/relr-relocs.test

Lines changed: 2 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,6 @@
11
## This is a test to test how SHT_RELR sections are dumped.
22

33
# RUN: yaml2obj --docnum=1 %s -o %t1
4-
# RUN: llvm-readobj --relocations --raw-relr %t1 \
5-
# RUN: | FileCheck --check-prefix=RAW-LLVM1 %s
6-
# RAW-LLVM1: Section (1) .relr.dyn {
7-
# RAW-LLVM1-NEXT: 0x10D60
8-
# RAW-LLVM1-NEXT: 0x103
9-
# RAW-LLVM1-NEXT: 0x20000
10-
# RAW-LLVM1-NEXT: 0xF0501
11-
# RAW-LLVM1-NEXT: 0xA700550400009
12-
# RAW-LLVM1-NEXT: }
13-
144
# RUN: llvm-readobj --relocations %t1 | \
155
# RUN: FileCheck --match-full-lines --check-prefix=LLVM1 %s
166

@@ -38,15 +28,6 @@
3828
# LLVM1-NEXT: 0x20390 R_X86_64_RELATIVE -
3929
# LLVM1-NEXT: }
4030

41-
# RUN: llvm-readelf --relocations --raw-relr %t1 \
42-
# RUN: | FileCheck --check-prefix=RAW-GNU1 %s
43-
# RAW-GNU1: Relocation section '.relr.dyn' at offset 0x40 contains 5 entries:
44-
# RAW-GNU1: 0000000000010d60
45-
# RAW-GNU1-NEXT: 0000000000000103
46-
# RAW-GNU1-NEXT: 0000000000020000
47-
# RAW-GNU1-NEXT: 00000000000f0501
48-
# RAW-GNU1-NEXT: 000a700550400009
49-
5031
# RUN: llvm-readelf --relocations %t1 | FileCheck --check-prefix=GNU1 --match-full-lines --strict-whitespace %s
5132
# GNU1:Relocation section '.relr.dyn' at offset 0x40 contains 21 entries:
5233
# GNU1-NEXT:Index: Entry Address Symbolic Address
@@ -107,16 +88,6 @@ Symbols:
10788
Value: 0x20210
10889

10990
# RUN: yaml2obj --docnum=2 %s -o %t2
110-
# RUN: llvm-readobj --relocations --raw-relr %t2 | \
111-
# RUN: FileCheck --check-prefix=RAW-LLVM2 %s
112-
# RAW-LLVM2: Section (1) .relr.dyn {
113-
# RAW-LLVM2-NEXT: 0x10D60
114-
# RAW-LLVM2-NEXT: 0x103
115-
# RAW-LLVM2-NEXT: 0x20000
116-
# RAW-LLVM2-NEXT: 0xF0501
117-
# RAW-LLVM2-NEXT: 0x50400009
118-
# RAW-LLVM2-NEXT: }
119-
12091
# RUN: llvm-readobj --relocations %t2 | \
12192
# RUN: FileCheck --match-full-lines --check-prefix=LLVM2 %s
12293

@@ -137,15 +108,6 @@ Symbols:
137108
# LLVM2-NEXT: 0x200F4 R_386_RELATIVE -
138109
# LLVM2-NEXT: }
139110

140-
# RUN: llvm-readelf --relocations --raw-relr %t2 | \
141-
# RUN: FileCheck --check-prefix=RAW-GNU2 %s
142-
# RAW-GNU2: Relocation section '.relr.dyn' at offset 0x34 contains 5 entries:
143-
# RAW-GNU2: 00010d60
144-
# RAW-GNU2-NEXT: 00000103
145-
# RAW-GNU2-NEXT: 00020000
146-
# RAW-GNU2-NEXT: 000f0501
147-
# RAW-GNU2-NEXT: 50400009
148-
149111
# RUN: llvm-readelf --relocations %t2 | FileCheck --check-prefix=GNU2 --match-full-lines --strict-whitespace %s
150112
# GNU2:Relocation section '.relr.dyn' at offset 0x34 contains 14 entries:
151113
# GNU2-NEXT:Index: Entry Address Symbolic Address
@@ -232,21 +194,14 @@ Symbols:
232194
## only relative relocations and do not have an associated symbol table, like other
233195
## relocation sections.
234196

235-
## Case A: check we do not report warnings when the sh_link field is set to an arbitrary value
236-
## and the --relocations option is requested.
197+
## Check we do not report warnings when the sh_link field is set to an arbitrary value
198+
## and the --relocations option is requested.
237199
# RUN: yaml2obj --docnum=2 -DLINK=0xff %s -o %t2.has.link
238200
# RUN: llvm-readobj --relocations %t2.has.link 2>&1 | \
239201
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=LLVM2 %s --implicit-check-not=warning:
240202
# RUN: llvm-readelf --relocations %t2.has.link 2>&1 | \
241203
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=GNU2 %s --implicit-check-not=warning:
242204

243-
## Case B: check we do not report warnings when the sh_link field is set to an arbitrary value
244-
## and --relocations and --raw-relr options are requested.
245-
# RUN: llvm-readobj --relocations --raw-relr %t2.has.link | \
246-
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-LLVM2 %s
247-
# RUN: llvm-readelf --relocations --raw-relr %t2.has.link 2>&1 | \
248-
# RUN: FileCheck -DFILE=%t2.has.link --check-prefix=RAW-GNU2 %s
249-
250205
## .symtab is invalid. Check we report a warning and print entries without symbolization.
251206
# RUN: yaml2obj --docnum=3 -DENTSIZE=1 %s -o %t3.err1
252207
# RUN: llvm-readelf -r %t3.err1 2>&1 | FileCheck -DFILE=%t3.err1 --check-prefixes=GNU3,GNU3-ERR1 --match-full-lines %s

llvm/tools/llvm-readobj/ELFDumper.cpp

Lines changed: 15 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,6 @@ template <typename ELFT> class ELFDumper : public ObjDumper {
285285

286286
virtual void printRelRelaReloc(const Relocation<ELFT> &R,
287287
const RelSymbol<ELFT> &RelSym) = 0;
288-
virtual void printRelrReloc(const Elf_Relr &R) = 0;
289288
virtual void printDynamicRelocHeader(unsigned Type, StringRef Name,
290289
const DynRegionInfo &Reg) {}
291290
void printReloc(const Relocation<ELFT> &R, unsigned RelIndex,
@@ -294,11 +293,10 @@ template <typename ELFT> class ELFDumper : public ObjDumper {
294293
void printDynamicRelocationsHelper();
295294
void printRelocationsHelper(const Elf_Shdr &Sec);
296295
void forEachRelocationDo(
297-
const Elf_Shdr &Sec, bool RawRelr,
296+
const Elf_Shdr &Sec,
298297
llvm::function_ref<void(const Relocation<ELFT> &, unsigned,
299298
const Elf_Shdr &, const Elf_Shdr *)>
300-
RelRelaFn,
301-
llvm::function_ref<void(const Elf_Relr &)> RelrFn);
299+
RelRelaFn);
302300

303301
virtual void printSymtabMessage(const Elf_Shdr *Symtab, size_t Offset,
304302
bool NonVisibilityBitsUsed,
@@ -669,7 +667,6 @@ template <typename ELFT> class GNUELFDumper : public ELFDumper<ELFT> {
669667
DataRegion<Elf_Word> ShndxTable, StringRef StrTable,
670668
uint32_t Bucket);
671669
void printRelr(const Elf_Shdr &Sec);
672-
void printRelrReloc(const Elf_Relr &R) override;
673670
void printRelRelaReloc(const Relocation<ELFT> &R,
674671
const RelSymbol<ELFT> &RelSym) override;
675672
void printSymbol(const Elf_Sym &Symbol, unsigned SymIndex,
@@ -734,7 +731,6 @@ template <typename ELFT> class LLVMELFDumper : public ELFDumper<ELFT> {
734731
bool IsGnu) const override;
735732

736733
private:
737-
void printRelrReloc(const Elf_Relr &R) override;
738734
void printRelRelaReloc(const Relocation<ELFT> &R,
739735
const RelSymbol<ELFT> &RelSym) override;
740736

@@ -3800,11 +3796,6 @@ template <class ELFT> void GNUELFDumper<ELFT>::printGroupSections() {
38003796
OS << "There are no section groups in this file.\n";
38013797
}
38023798

3803-
template <class ELFT>
3804-
void GNUELFDumper<ELFT>::printRelrReloc(const Elf_Relr &R) {
3805-
OS << to_string(format_hex_no_prefix(R, ELFT::Is64Bits ? 16 : 8)) << "\n";
3806-
}
3807-
38083799
template <class ELFT>
38093800
void GNUELFDumper<ELFT>::printRelRelaReloc(const Relocation<ELFT> &R,
38103801
const RelSymbol<ELFT> &RelSym) {
@@ -3851,22 +3842,11 @@ template <class ELFT>
38513842
static void printRelocHeaderFields(formatted_raw_ostream &OS, unsigned SType,
38523843
const typename ELFT::Ehdr &EHeader) {
38533844
bool IsRela = SType == ELF::SHT_RELA || SType == ELF::SHT_ANDROID_RELA;
3854-
bool IsRelr =
3855-
SType == ELF::SHT_RELR || SType == ELF::SHT_ANDROID_RELR ||
3856-
(EHeader.e_machine == EM_AARCH64 && SType == ELF::SHT_AARCH64_AUTH_RELR);
3857-
if (ELFT::Is64Bits)
3858-
OS << " ";
3859-
else
3860-
OS << " ";
3861-
if (IsRelr && opts::RawRelr)
3862-
OS << "Data ";
3863-
else
3864-
OS << "Offset";
38653845
if (ELFT::Is64Bits)
3866-
OS << " Info Type"
3867-
<< " Symbol's Value Symbol's Name";
3846+
OS << " Offset Info Type Symbol's "
3847+
"Value Symbol's Name";
38683848
else
3869-
OS << " Info Type Sym. Value Symbol's Name";
3849+
OS << " Offset Info Type Sym. Value Symbol's Name";
38703850
if (IsRela)
38713851
OS << " + Addend";
38723852
OS << "\n";
@@ -3894,10 +3874,10 @@ static bool isRelocationSec(const typename ELFT::Shdr &Sec,
38943874

38953875
template <class ELFT> void GNUELFDumper<ELFT>::printRelocations() {
38963876
auto PrintAsRelr = [&](const Elf_Shdr &Sec) {
3897-
return !opts::RawRelr && (Sec.sh_type == ELF::SHT_RELR ||
3898-
Sec.sh_type == ELF::SHT_ANDROID_RELR ||
3899-
(this->Obj.getHeader().e_machine == EM_AARCH64 &&
3900-
Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR));
3877+
return Sec.sh_type == ELF::SHT_RELR ||
3878+
Sec.sh_type == ELF::SHT_ANDROID_RELR ||
3879+
(this->Obj.getHeader().e_machine == EM_AARCH64 &&
3880+
Sec.sh_type == ELF::SHT_AARCH64_AUTH_RELR);
39013881
};
39023882
auto GetEntriesNum = [&](const Elf_Shdr &Sec) -> Expected<size_t> {
39033883
// Android's packed relocation section needs to be unpacked first
@@ -4902,10 +4882,8 @@ void ELFDumper<ELFT>::printDynamicReloc(const Relocation<ELFT> &R) {
49024882
template <class ELFT>
49034883
void ELFDumper<ELFT>::printRelocationsHelper(const Elf_Shdr &Sec) {
49044884
this->forEachRelocationDo(
4905-
Sec, opts::RawRelr,
4906-
[&](const Relocation<ELFT> &R, unsigned Ndx, const Elf_Shdr &Sec,
4907-
const Elf_Shdr *SymTab) { printReloc(R, Ndx, Sec, SymTab); },
4908-
[&](const Elf_Relr &R) { printRelrReloc(R); });
4885+
Sec, [&](const Relocation<ELFT> &R, unsigned Ndx, const Elf_Shdr &Sec,
4886+
const Elf_Shdr *SymTab) { printReloc(R, Ndx, Sec, SymTab); });
49094887
}
49104888

49114889
template <class ELFT> void ELFDumper<ELFT>::printDynamicRelocationsHelper() {
@@ -6371,11 +6349,10 @@ void ELFDumper<ELFT>::printDependentLibsHelper(
63716349

63726350
template <class ELFT>
63736351
void ELFDumper<ELFT>::forEachRelocationDo(
6374-
const Elf_Shdr &Sec, bool RawRelr,
6352+
const Elf_Shdr &Sec,
63756353
llvm::function_ref<void(const Relocation<ELFT> &, unsigned,
63766354
const Elf_Shdr &, const Elf_Shdr *)>
6377-
RelRelaFn,
6378-
llvm::function_ref<void(const Elf_Relr &)> RelrFn) {
6355+
RelRelaFn) {
63796356
auto Warn = [&](Error &&E,
63806357
const Twine &Prefix = "unable to read relocations from") {
63816358
this->reportUniqueWarning(Prefix + " " + describe(Sec) + ": " +
@@ -6427,11 +6404,6 @@ void ELFDumper<ELFT>::forEachRelocationDo(
64276404
Warn(RangeOrErr.takeError());
64286405
break;
64296406
}
6430-
if (RawRelr) {
6431-
for (const Elf_Relr &R : *RangeOrErr)
6432-
RelrFn(R);
6433-
break;
6434-
}
64356407

64366408
for (const Elf_Rel &R : Obj.decode_relrs(*RangeOrErr))
64376409
RelRelaFn(Relocation<ELFT>(R, IsMips64EL), RelNdx++, Sec,
@@ -6741,9 +6713,8 @@ void ELFDumper<ELFT>::printRelocatableStackSizes(
67416713
DataExtractor Data(Contents, Obj.isLE(), sizeof(Elf_Addr));
67426714

67436715
forEachRelocationDo(
6744-
*RelocSec, /*RawRelr=*/false,
6745-
[&](const Relocation<ELFT> &R, unsigned Ndx, const Elf_Shdr &Sec,
6746-
const Elf_Shdr *SymTab) {
6716+
*RelocSec, [&](const Relocation<ELFT> &R, unsigned Ndx,
6717+
const Elf_Shdr &Sec, const Elf_Shdr *SymTab) {
67476718
if (!IsSupportedFn || !IsSupportedFn(R.Type)) {
67486719
reportUniqueWarning(
67496720
describe(*RelocSec) +
@@ -6754,10 +6725,6 @@ void ELFDumper<ELFT>::printRelocatableStackSizes(
67546725

67556726
this->printStackSize(R, *RelocSec, Ndx, SymTab, FunctionSec,
67566727
*StackSizesELFSec, Resolver, Data);
6757-
},
6758-
[](const Elf_Relr &) {
6759-
llvm_unreachable("can't get here, because we only support "
6760-
"SHT_REL/SHT_RELA sections");
67616728
});
67626729
}
67636730
}
@@ -7147,11 +7114,6 @@ template <class ELFT> void LLVMELFDumper<ELFT>::printRelocations() {
71477114
}
71487115
}
71497116

7150-
template <class ELFT>
7151-
void LLVMELFDumper<ELFT>::printRelrReloc(const Elf_Relr &R) {
7152-
W.startLine() << W.hex(R) << "\n";
7153-
}
7154-
71557117
template <class ELFT>
71567118
void LLVMELFDumper<ELFT>::printExpandedRelRelaReloc(const Relocation<ELFT> &R,
71577119
StringRef SymbolName,

llvm/tools/llvm-readobj/Opts.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,6 @@ def memtag : FF<"memtag", "Display memory tagging metadata (modes, Android notes
6262
def needed_libs : FF<"needed-libs", "Display the needed libraries">, Group<grp_elf>;
6363
def notes : FF<"notes", "Display notes">, Group<grp_elf>;
6464
def program_headers : FF<"program-headers", "Display program headers">, Group<grp_elf>;
65-
def raw_relr : FF<"raw-relr", "Do not decode relocations in SHT_RELR section, display raw contents">, Group<grp_elf>;
6665
def version_info : FF<"version-info", "Display version sections">, Group<grp_elf>;
6766

6867
// Mach-O specific options.

llvm/tools/llvm-readobj/llvm-readobj.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,6 @@ static bool Memtag;
134134
static bool NeededLibraries;
135135
static bool Notes;
136136
static bool ProgramHeaders;
137-
bool RawRelr;
138137
static bool SectionGroups;
139138
static bool VersionInfo;
140139

@@ -273,7 +272,6 @@ static void parseOptions(const opt::InputArgList &Args) {
273272
opts::Notes = Args.hasArg(OPT_notes);
274273
opts::PrettyPrint = Args.hasArg(OPT_pretty_print);
275274
opts::ProgramHeaders = Args.hasArg(OPT_program_headers);
276-
opts::RawRelr = Args.hasArg(OPT_raw_relr);
277275
opts::SectionGroups = Args.hasArg(OPT_section_groups);
278276
if (Arg *A = Args.getLastArg(OPT_sort_symbols_EQ)) {
279277
std::string SortKeysString = A->getValue();

llvm/tools/llvm-readobj/llvm-readobj.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ extern bool SectionRelocations;
3838
extern bool SectionSymbols;
3939
extern bool SectionData;
4040
extern bool ExpandRelocs;
41-
extern bool RawRelr;
4241
extern bool CodeViewSubsectionBytes;
4342
extern bool Demangle;
4443
enum OutputStyleTy { LLVM, GNU, JSON, UNKNOWN };

0 commit comments

Comments
 (0)