@@ -636,7 +636,7 @@ static const struct note_tag_t
636636 { { NT_SPU, " NT_SPU" , " " }
637637 } },
638638 { " GNU" ,
639- {
639+ {
640640 { NT_GNU_ABI_TAG, " NT_GNU_ABI_TAG" , " GNU ABI tag" },
641641 { NT_GNU_HWCAP, " NT_GNU_HWCAP" , " Used by ld.so and kernel vDSO" },
642642 { NT_GNU_BUILD_ID, " NT_GNU_BUILD_ID" , " Build ID of the binary" },
@@ -862,7 +862,7 @@ class dump
862862 }
863863 else { // Output for 64-bit
864864 out << " [" << DUMP_DEC_FORMAT ( 5 ) << no << " ] "
865- << DUMP_STR_FORMAT ( 14 ) << str_segment_type ( seg->get_type () ) << " "
865+ << DUMP_STR_FORMAT ( 14 ) << str_segment_type ( seg->get_type () ) << " "
866866 << DUMP_HEX0x_FORMAT ( 16 ) << seg->get_offset () << " "
867867 << DUMP_HEX0x_FORMAT ( 16 ) << seg->get_virtual_address () << " "
868868 << DUMP_HEX0x_FORMAT ( 16 ) << seg->get_physical_address ()
@@ -871,7 +871,7 @@ class dump
871871 << DUMP_HEX0x_FORMAT ( 16 ) << seg->get_file_size () << " "
872872 << DUMP_HEX0x_FORMAT ( 16 ) << seg->get_memory_size () << " "
873873 << DUMP_STR_FORMAT ( 3 ) << str_segment_flag ( seg->get_flags () ) << " "
874- << DUMP_HEX0x_FORMAT ( 1 ) << seg->get_align ()
874+ << DUMP_HEX0x_FORMAT ( 1 ) << seg->get_align ()
875875 << std::endl;
876876 }
877877 // clang-format on
@@ -1100,7 +1100,7 @@ class dump
11001100
11011101 // ------------------------------------------------------------------------------
11021102 // Dumps the dynamic tags information
1103- static void dynamic_tags ( std::ostream& out, const elfio& reader )
1103+ static void dynamic_tags ( std::ostream& out, const elfio& reader, bool name_only = false )
11041104 {
11051105 for ( const auto & sec : reader.sections ) { // For all sections
11061106 if ( SHT_DYNAMIC == sec->get_type () ) {
@@ -1109,22 +1109,24 @@ class dump
11091109 Elf_Xword dyn_no = dynamic.get_entries_num ();
11101110 if ( dyn_no == 0 )
11111111 continue ;
1112-
1113- out << " Dynamic section (" << sec->get_name () << " )"
1114- << std::endl;
1115- out << " [ Nr ] Tag Name/Value" << std::endl;
1112+ if ( !name_only ) {
1113+ out << " Dynamic section (" << sec->get_name () << " )"
1114+ << std::endl;
1115+ out << " [ Nr ] Tag Name/Value" << std::endl;
1116+ }
11161117 for ( Elf_Xword i = 0 ; i < dyn_no; ++i ) {
11171118 Elf_Xword tag = 0 ;
11181119 Elf_Xword value = 0 ;
11191120 std::string str;
11201121 dynamic.get_entry ( i, tag, value, str );
1121- dynamic_tag ( out, i, tag, value, str, reader.get_class () );
1122+ dynamic_tag ( out, i, tag, value, str, reader.get_class (), name_only );
11221123 if ( DT_NULL == tag ) {
11231124 break ;
11241125 }
11251126 }
1126-
1127- out << std::endl;
1127+ if ( !name_only ) {
1128+ out << std::endl;
1129+ }
11281130 }
11291131 }
11301132 }
@@ -1136,8 +1138,16 @@ class dump
11361138 Elf_Xword tag,
11371139 Elf_Xword value,
11381140 const std::string& str,
1139- unsigned int /* elf_class*/ )
1141+ unsigned int /* elf_class*/ ,
1142+ bool name_only = false )
11401143 {
1144+ if ( name_only ) {
1145+ if ( str.empty () || tag != DT_NEEDED ) {
1146+ return ;
1147+ }
1148+ out << str << std::endl;
1149+ return ;
1150+ }
11411151 out << " [" << DUMP_DEC_FORMAT ( 5 ) << no << " ] "
11421152 << DUMP_STR_FORMAT ( 16 ) << str_dynamic_tag ( tag ) << " " ;
11431153 if ( str.empty () ) {
0 commit comments