static bool
dump_relr_relocations (Filedata * filedata,
- Elf_Internal_Shdr * section,
+ uint64_t relr_size,
+ int relr_entsize,
+ uint64_t relr_offset,
Elf_Internal_Sym * symtab,
uint64_t nsyms,
char * strtab,
{
uint64_t * relrs;
uint64_t nentries, i;
- uint64_t relr_size = section->sh_size;
- int relr_entsize = section->sh_entsize;
- uint64_t relr_offset = section->sh_offset;
uint64_t where = 0;
int num_bits_in_entry;
bool res;
if (rel_type == reltype_relr)
- res = dump_relr_relocations (filedata, section, symtab, nsyms, strtab, strtablen);
+ res = dump_relr_relocations (filedata, section->sh_size,
+ section->sh_entsize,
+ section->sh_offset,
+ symtab, nsyms, strtab, strtablen);
else
res = dump_relocations (filedata, rel_offset, rel_size,
symtab, nsyms, strtab, strtablen,
for (i = 0; i < ARRAY_SIZE (dynamic_relocations); i++)
{
+ rel_size = filedata->dynamic_info[dynamic_relocations [i].size];
+
+ if (!rel_size)
+ continue;
+
+ has_dynamic_reloc = true;
+
rel_type = dynamic_relocations [i].rel_type;
name = dynamic_relocations [i].name;
- rel_size = filedata->dynamic_info[dynamic_relocations [i].size];
rel_offset = filedata->dynamic_info[dynamic_relocations [i].reloc];
- if (rel_size)
- has_dynamic_reloc = true;
-
if (rel_type == reltype_unknown)
{
- if (dynamic_relocations [i].reloc == DT_JMPREL)
- switch (filedata->dynamic_info[DT_PLTREL])
- {
- case DT_REL:
- rel_type = reltype_rel;
- break;
- case DT_RELA:
- rel_type = reltype_rela;
- break;
- }
- }
-
- if (rel_size)
- {
- if (filedata->is_separate)
- printf
- (_("\nIn linked file '%s' section '%s' at offset %#" PRIx64
- " contains %" PRId64 " bytes:\n"),
- filedata->file_name, name, rel_offset, rel_size);
- else
- printf
- (_("\n'%s' relocation section at offset %#" PRIx64
- " contains %" PRId64 " bytes:\n"),
- name, rel_offset, rel_size);
-
- dump_relocations (filedata,
- offset_from_vma (filedata, rel_offset, rel_size),
- rel_size,
- filedata->dynamic_symbols,
- filedata->num_dynamic_syms,
- filedata->dynamic_strings,
- filedata->dynamic_strings_length,
- rel_type, true /* is_dynamic */);
+ if (dynamic_relocations [i].reloc != DT_JMPREL)
+ abort ();
+ switch (filedata->dynamic_info[DT_PLTREL])
+ {
+ case DT_REL:
+ rel_type = reltype_rel;
+ break;
+ case DT_RELA:
+ rel_type = reltype_rela;
+ break;
+ }
}
- }
- if (is_ia64_vms (filedata))
- if (process_ia64_vms_dynamic_relocs (filedata))
- has_dynamic_reloc = true;
+ if (filedata->is_separate)
+ printf
+ (_("\nIn linked file '%s' section '%s' at offset %#" PRIx64
+ " contains %" PRId64 " bytes:\n"),
+ filedata->file_name, name, rel_offset, rel_size);
+ else
+ printf
+ (_("\n'%s' relocation section at offset %#" PRIx64
+ " contains %" PRId64 " bytes:\n"),
+ name, rel_offset, rel_size);
+
+ if (rel_type == reltype_relr)
+ dump_relr_relocations (filedata,
+ filedata->dynamic_info[DT_RELRSZ],
+ filedata->dynamic_info[DT_RELRENT],
+ filedata->dynamic_info[DT_RELR],
+ filedata->dynamic_symbols,
+ filedata->num_dynamic_syms,
+ filedata->dynamic_strings,
+ filedata->dynamic_strings_length);
+ else
+ dump_relocations (filedata,
+ offset_from_vma (filedata, rel_offset,
+ rel_size),
+ rel_size,
+ filedata->dynamic_symbols,
+ filedata->num_dynamic_syms,
+ filedata->dynamic_strings,
+ filedata->dynamic_strings_length,
+ rel_type, true /* is_dynamic */);
+ }
+
+ if (is_ia64_vms (filedata)
+ && process_ia64_vms_dynamic_relocs (filedata))
+ has_dynamic_reloc = true;
if (! has_dynamic_reloc)
{
--- /dev/null
+#source: dt-relr-1.s
+#as: --32
+#ld: -shared -melf_i386 $DT_RELR_LDFLAGS --hash-style=sysv
+#readelf: -D -r -s --wide
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+'REL' relocation section at offset [0x0-9a-f]+ contains 16 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+
+'RELR' relocation section at offset 0x[a-f0-9]+ contains 8 bytes:
+#...
+0000: +[0-9a-f]+ [0-9a-f]+ +.*
+0001: +[0-9a-f]+ [0-9a-f]+ +.*
+ +[0-9a-f]+ +.*
+#...
+'PLT' relocation section at offset 0x[0-9a-f]+ contains 8 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func1
+
+Symbol table for image contains [0-9]+ entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ +[0-9]+: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +func1
+#pass
--- /dev/null
+#source: dt-relr-1.s
+#as: --32
+#ld: -shared -melf_i386 $DT_RELR_LDFLAGS -z nocombreloc --hash-style=sysv
+#readelf: -D -r -s --wide
+#target: x86_64-*-linux* i?86-*-linux-gnu i?86-*-gnu*
+
+'REL' relocation section at offset [0x0-9a-f]+ contains 16 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+[0-9a-f]+ +[0-9a-f]+ +R_386_32 +0+ +data1
+
+'RELR' relocation section at offset 0x[a-f0-9]+ contains 8 bytes:
+#...
+0000: +[0-9a-f]+ [0-9a-f]+ +.*
+0001: +[0-9a-f]+ [0-9a-f]+ +.*
+ +[0-9a-f]+ +.*
+#...
+'PLT' relocation section at offset 0x[0-9a-f]+ contains 8 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name
+[0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func1
+
+Symbol table for image contains [0-9]+ entries:
+ Num: Value Size Type Bind Vis Ndx Name
+#...
+ +[0-9]+: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +func1
+#pass
run_dump_test "pr27491-4"
run_dump_test "dt-relr-1a"
run_dump_test "dt-relr-1b"
+run_dump_test "dt-relr-1c"
+run_dump_test "dt-relr-1d"
run_dump_test "pr28870"
run_dump_test "pr28894"
run_dump_test "pr30787"
--- /dev/null
+#source: dt-relr-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64 $DT_RELR_LDFLAGS -z nomark-plt --hash-style=sysv
+#readelf: -D -r -s --wide
+#target: x86_64-*-linux*
+
+'RELA' relocation section at offset 0x[0-9a-f]+ contains 24 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+
+'RELR' relocation section at offset 0x[a-f0-9]+ contains 8 bytes:
+#...
+0000: +[0-9a-f]+ [0-9a-f]+ +.*
+0001: +[0-9a-f]+ [0-9a-f]+ +.*
+ +[0-9a-f]+ +.*
+#...
+'PLT' relocation section at offset 0x[0-9a-f]+ contains 12 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Symbol table for image contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +func1
+#pass
--- /dev/null
+#source: dt-relr-1.s
+#as: --64
+#ld: -shared -melf_x86_64 $DT_RELR_LDFLAGS -z nomark-plt --hash-style=sysv
+#readelf: -D -r -s --wide
+#target: x86_64-*-linux*
+
+'RELA' relocation section at offset 0x[0-9a-f]+ contains 48 bytes:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+
+'RELR' relocation section at offset 0x[a-f0-9]+ contains 16 bytes:
+#...
+0000: +[0-9a-f]+ [0-9a-f]+ +.*
+0001: +[0-9a-f]+ [0-9a-f]+ +.*
+ +[0-9a-f]+ +.*
+#...
+'PLT' relocation section at offset 0x[0-9a-f]+ contains 24 bytes:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Symbol table for image contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +func1
+#pass
--- /dev/null
+#source: dt-relr-1.s
+#as: --x32
+#ld: -shared -melf32_x86_64 $DT_RELR_LDFLAGS -z nocombreloc -z nomark-plt --hash-style=sysv
+#readelf: -D -r -s --wide
+#target: x86_64-*-linux*
+
+'RELA' relocation section at offset 0x[0-9a-f]+ contains 24 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_32 +0+ +data1 \+ 0
+
+'RELR' relocation section at offset 0x[a-f0-9]+ contains 8 bytes:
+#...
+0000: +[0-9a-f]+ [0-9a-f]+ +.*
+0001: +[0-9a-f]+ [0-9a-f]+ +.*
+ +[0-9a-f]+ +.*
+#...
+'PLT' relocation section at offset 0x[0-9a-f]+ contains 12 bytes:
+ +Offset +Info +Type +Sym. Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Symbol table for image contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +func1
+#pass
--- /dev/null
+#source: dt-relr-1.s
+#as: --64
+#ld: -shared -melf_x86_64 $DT_RELR_LDFLAGS -z nocombreloc -z nomark-plt --hash-style=sysv
+#readelf: -D -r -s --wide
+#target: x86_64-*-linux*
+
+'RELA' relocation section at offset 0x[0-9a-f]+ contains 48 bytes:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_64 +0+ +data1 \+ 0
+
+'RELR' relocation section at offset 0x[a-f0-9]+ contains 16 bytes:
+#...
+0000: +[0-9a-f]+ [0-9a-f]+ +.*
+0001: +[0-9a-f]+ [0-9a-f]+ +.*
+ +[0-9a-f]+ +.*
+#...
+'PLT' relocation section at offset 0x[0-9a-f]+ contains 24 bytes:
+ +Offset +Info +Type +Symbol's Value +Symbol's Name \+ Addend
+[0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0
+
+Symbol table for image contains [0-9]+ entries:
+ +Num: +Value +Size Type +Bind +Vis +Ndx Name
+#...
+ +[0-9]+: 0+ +0 +NOTYPE +GLOBAL +DEFAULT +UND +func1
+#pass
run_dump_test "dt-relr-1a-x32"
run_dump_test "dt-relr-1b"
run_dump_test "dt-relr-1b-x32"
+run_dump_test "dt-relr-1c"
+run_dump_test "dt-relr-1c-x32"
+run_dump_test "dt-relr-1d"
+run_dump_test "dt-relr-1d-x32"
run_dump_test "pr30787"
run_dump_test "pr31047"
run_dump_test "pr31047-x32"