@@ -4502,26 +4502,26 @@ void GNUStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
4502
4502
}
4503
4503
};
4504
4504
4505
- if (Obj-> getHeader ()-> e_type == ELF::ET_CORE || Obj->sections ()-> empty ()) {
4506
- for ( const auto &P :
4507
- unwrapOrError ( this -> FileName , Obj-> program_headers ()) ) {
4508
- if (P. p_type != PT_NOTE )
4505
+ ArrayRef<Elf_Shdr> Sections = unwrapOrError ( this -> FileName , Obj->sections ());
4506
+ if (Obj-> getHeader ()-> e_type != ELF::ET_CORE && !Sections. empty ()) {
4507
+ for ( const auto &S : Sections ) {
4508
+ if (S. sh_type != SHT_NOTE )
4509
4509
continue ;
4510
- PrintHeader (P. p_offset , P. p_filesz );
4510
+ PrintHeader (S. sh_offset , S. sh_size );
4511
4511
Error Err = Error::success ();
4512
- for (const auto &Note : Obj->notes (P , Err))
4512
+ for (const auto &Note : Obj->notes (S , Err))
4513
4513
ProcessNote (Note);
4514
4514
if (Err)
4515
4515
reportError (std::move (Err), this ->FileName );
4516
4516
}
4517
4517
} else {
4518
- for (const auto &S :
4519
- unwrapOrError (this ->FileName , Obj->sections ())) {
4520
- if (S. sh_type != SHT_NOTE )
4518
+ for (const auto &P :
4519
+ unwrapOrError (this ->FileName , Obj->program_headers ())) {
4520
+ if (P. p_type != PT_NOTE )
4521
4521
continue ;
4522
- PrintHeader (S. sh_offset , S. sh_size );
4522
+ PrintHeader (P. p_offset , P. p_filesz );
4523
4523
Error Err = Error::success ();
4524
- for (const auto &Note : Obj->notes (S , Err))
4524
+ for (const auto &Note : Obj->notes (P , Err))
4525
4525
ProcessNote (Note);
4526
4526
if (Err)
4527
4527
reportError (std::move (Err), this ->FileName );
@@ -5703,27 +5703,28 @@ void LLVMStyle<ELFT>::printNotes(const ELFFile<ELFT> *Obj) {
5703
5703
}
5704
5704
};
5705
5705
5706
- if (Obj-> getHeader ()-> e_type == ELF::ET_CORE || Obj->sections ()-> empty ()) {
5707
- for ( const auto &P :
5708
- unwrapOrError ( this -> FileName , Obj-> program_headers ()) ) {
5709
- if (P. p_type != PT_NOTE )
5706
+ ArrayRef<Elf_Shdr> Sections = unwrapOrError ( this -> FileName , Obj->sections ());
5707
+ if (Obj-> getHeader ()-> e_type != ELF::ET_CORE && !Sections. empty ()) {
5708
+ for ( const auto &S : Sections ) {
5709
+ if (S. sh_type != SHT_NOTE )
5710
5710
continue ;
5711
5711
DictScope D (W, " NoteSection" );
5712
- PrintHeader (P. p_offset , P. p_filesz );
5712
+ PrintHeader (S. sh_offset , S. sh_size );
5713
5713
Error Err = Error::success ();
5714
- for (const auto &Note : Obj->notes (P , Err))
5714
+ for (const auto &Note : Obj->notes (S , Err))
5715
5715
ProcessNote (Note);
5716
5716
if (Err)
5717
5717
reportError (std::move (Err), this ->FileName );
5718
5718
}
5719
5719
} else {
5720
- for (const auto &S : unwrapOrError (this ->FileName , Obj->sections ())) {
5721
- if (S.sh_type != SHT_NOTE)
5720
+ for (const auto &P :
5721
+ unwrapOrError (this ->FileName , Obj->program_headers ())) {
5722
+ if (P.p_type != PT_NOTE)
5722
5723
continue ;
5723
5724
DictScope D (W, " NoteSection" );
5724
- PrintHeader (S. sh_offset , S. sh_size );
5725
+ PrintHeader (P. p_offset , P. p_filesz );
5725
5726
Error Err = Error::success ();
5726
- for (const auto &Note : Obj->notes (S , Err))
5727
+ for (const auto &Note : Obj->notes (P , Err))
5727
5728
ProcessNote (Note);
5728
5729
if (Err)
5729
5730
reportError (std::move (Err), this ->FileName );
0 commit comments