Browse code

walkDynamic(): display the linked section.

... and since it is supposed to be a strtab, use it to explain DT_NEEDED
entries.

Xavier G authored on 10/09/2015 00:30:08
Showing 1 changed files
... ...
@@ -3084,6 +3084,9 @@ sub walkDynamic {
3084 3084
 	my $section = $elf_data->{'sections'}->{$section_index};
3085 3085
 	return if (!defined($section));
3086 3086
 
3087
+	# Where should we read names from?
3088
+	my $strtab = displayStringTableForSection($ind, $elf_data, $section_index);
3089
+
3087 3090
 	# What kind of entries do we intend to read?
3088 3091
 	my $arch = $elf_data->{'EI_CLASS'};
3089 3092
 	my $dyn_info = $elf_structures->{'dynamic'}->{$arch};
... ...
@@ -3111,14 +3114,11 @@ sub walkDynamic {
3111 3114
 					# "The offset is an index into the table recorded in the DT_STRTAB code."
3112 3115
 					# ... except we are liable to read a DT_NEEDED entry before
3113 3116
 					# stumbling upon the DT_STRTAB one.
3114
-					# We can assume DT_STRTAB actually points to a SHT_STRTAB
3115
-					# section, typically .dynstr
3116
-					for my $section_index (keys(%{$elf_data->{'sections'}})) {
3117
-						my $section = $elf_data->{'sections'}->{$section_index};
3118
-						if ($section->{'_name'} eq '.dynstr') {
3119
-							displayStringFromSection($ind + 1, $elf_fh, $elf_data, $section_index, $value);
3120
-							last;
3121
-						}
3117
+					# As DT_STRTAB is supposed to point to a SHT_STRTAB section,
3118
+					# typically .dynstr, we can assume everything will be fine
3119
+					# if we rely on the linked strtab.
3120
+					if ($strtab) {
3121
+						displayStringFromSection($ind + 1, $elf_fh, $elf_data, $strtab, $value);
3122 3122
 					}
3123 3123
 				}
3124 3124
 				elsif ($tag_value == 20) { # DT_PLTREL