@@ -163,16 +163,10 @@ uint64_t llvm::getELFSectionLMA(const object::ELFSectionRef &Sec) {
163
163
164
164
template <class ELFT >
165
165
void printDynamicSection (const ELFFile<ELFT> *Elf, StringRef Filename) {
166
- auto ProgramHeaderOrError = Elf->program_headers ();
167
- if (!ProgramHeaderOrError)
168
- report_error (Filename, ProgramHeaderOrError.takeError ());
169
-
170
- auto DynamicEntriesOrError = Elf->dynamicEntries ();
171
- if (!DynamicEntriesOrError)
172
- report_error (Filename, DynamicEntriesOrError.takeError ());
173
-
166
+ ArrayRef<typename ELFT::Dyn> DynamicEntries =
167
+ unwrapOrError (Elf->dynamicEntries (), Filename);
174
168
outs () << " Dynamic Section:\n " ;
175
- for (const auto &Dyn : *DynamicEntriesOrError ) {
169
+ for (const typename ELFT::Dyn &Dyn : DynamicEntries ) {
176
170
if (Dyn.d_tag == ELF::DT_NULL)
177
171
continue ;
178
172
@@ -331,34 +325,23 @@ void printSymbolVersionDefinition(const typename ELFT::Shdr &Shdr,
331
325
332
326
template <class ELFT >
333
327
void printSymbolVersionInfo (const ELFFile<ELFT> *Elf, StringRef FileName) {
334
- typedef typename ELFT::Shdr Elf_Shdr;
335
-
336
- auto SectionsOrError = Elf->sections ();
337
- if (!SectionsOrError)
338
- report_error (FileName, SectionsOrError.takeError ());
339
-
340
- for (const Elf_Shdr &Shdr : *SectionsOrError) {
328
+ ArrayRef<typename ELFT::Shdr> Sections =
329
+ unwrapOrError (Elf->sections (), FileName);
330
+ for (const typename ELFT::Shdr &Shdr : Sections) {
341
331
if (Shdr.sh_type != ELF::SHT_GNU_verneed &&
342
332
Shdr.sh_type != ELF::SHT_GNU_verdef)
343
333
continue ;
344
334
345
- auto ContentsOrError = Elf->getSectionContents (&Shdr);
346
- if (!ContentsOrError)
347
- report_error (FileName, ContentsOrError.takeError ());
348
-
349
- auto StrTabSecOrError = Elf->getSection (Shdr.sh_link );
350
- if (!StrTabSecOrError)
351
- report_error (FileName, StrTabSecOrError.takeError ());
352
-
353
- auto StrTabOrError = Elf->getStringTable (*StrTabSecOrError);
354
- if (!StrTabOrError)
355
- report_error (FileName, StrTabOrError.takeError ());
335
+ ArrayRef<uint8_t > Contents =
336
+ unwrapOrError (Elf->getSectionContents (&Shdr), FileName);
337
+ const typename ELFT::Shdr *StrTabSec =
338
+ unwrapOrError (Elf->getSection (Shdr.sh_link ), FileName);
339
+ StringRef StrTab = unwrapOrError (Elf->getStringTable (StrTabSec), FileName);
356
340
357
341
if (Shdr.sh_type == ELF::SHT_GNU_verneed)
358
- printSymbolVersionDependency<ELFT>(*ContentsOrError, *StrTabOrError );
342
+ printSymbolVersionDependency<ELFT>(Contents, StrTab );
359
343
else
360
- printSymbolVersionDefinition<ELFT>(Shdr, *ContentsOrError,
361
- *StrTabOrError);
344
+ printSymbolVersionDefinition<ELFT>(Shdr, Contents, StrTab);
362
345
}
363
346
}
364
347
0 commit comments