From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2124) id A690D385840F; Thu, 11 Apr 2024 15:57:37 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A690D385840F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1712851057; bh=2xgDes2X5Jo52Xixox0pldisH4LtiaVoCgGDpRG8PqQ=; h=From:To:Subject:Date:From; b=PuR/T9+MANN6iGCZZs5GFAkaXt36HkNxBi3nTzjW65I6YVfCWH2IP808pTCTv8V8x 1AHa6touxyeknoIimHvY8MORjDkqiWXw6CJRfd8Kih4ToE0GGB8PH/sZCHVO8u1Pdw Dzt4Ba4EMXV0s9K/AK3EIaAY5Ea1lyJUemA6I6n4= Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: Nick Clifton To: binutils-cvs@sourceware.org Subject: [binutils-gdb] Improve readelf's display of RELR relocs. X-Act-Checkin: binutils-gdb X-Git-Author: Nick Clifton X-Git-Refname: refs/heads/master X-Git-Oldrev: 8e8d0b63ff15896cc2c228c01f18dfcf2a4a9305 X-Git-Newrev: fcf8f3237cbaa0f97e57a161d7354cdb89a1ffa4 Message-Id: <20240411155737.A690D385840F@sourceware.org> Date: Thu, 11 Apr 2024 15:57:37 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=3Dbinutils-gdb.git;h=3Dfcf8f3237cba= a0f97e57a161d7354cdb89a1ffa4 commit fcf8f3237cbaa0f97e57a161d7354cdb89a1ffa4 Author: Nick Clifton Date: Thu Apr 11 16:57:18 2024 +0100 Improve readelf's display of RELR relocs. Diff: --- binutils/NEWS | 2 + binutils/readelf.c | 414 +++++++++++++++++++-----= ---- binutils/testsuite/binutils-all/readelf.exp | 67 +++++ binutils/testsuite/binutils-all/relr.s | 13 + ld/testsuite/ld-elf/dt-relr-2b.d | 6 +- ld/testsuite/ld-elf/dt-relr-2c.d | 5 +- ld/testsuite/ld-elf/dt-relr-2d.d | 6 +- ld/testsuite/ld-elf/dt-relr-2e.d | 6 +- ld/testsuite/ld-elf/dt-relr-2i.d | 6 +- ld/testsuite/ld-i386/dt-relr-1a.d | 9 +- ld/testsuite/ld-i386/dt-relr-1b.d | 9 +- ld/testsuite/ld-powerpc/abs-pie-relr.r | 4 +- ld/testsuite/ld-powerpc/abs-shared-relr.r | 5 +- ld/testsuite/ld-x86-64/dt-relr-1a-x32.d | 9 +- ld/testsuite/ld-x86-64/dt-relr-1a.d | 9 +- ld/testsuite/ld-x86-64/dt-relr-1b-x32.d | 9 +- ld/testsuite/ld-x86-64/dt-relr-1b.d | 9 +- 17 files changed, 420 insertions(+), 168 deletions(-) diff --git a/binutils/NEWS b/binutils/NEWS index be744e3b2c4..5c31953575a 100644 --- a/binutils/NEWS +++ b/binutils/NEWS @@ -1,5 +1,7 @@ -*- text -*- =20 +* Readelf now displays RELR relocations in full detail. + * Readelf now has a -j/--display-section option which takes the name or in= dex of a section and displays its contents according to its type. The optio= n can be used multiple times on the command line to display multiple sections. diff --git a/binutils/readelf.c b/binutils/readelf.c index fa0de3a7e0d..fcf95ee3047 100644 --- a/binutils/readelf.c +++ b/binutils/readelf.c @@ -338,6 +338,7 @@ typedef enum print_mode PREFIX_HEX_5, FULL_HEX, LONG_HEX, + ZERO_HEX, OCTAL, OCTAL_5 } @@ -580,6 +581,11 @@ print_vma (uint64_t vma, print_mode mode) return nc + printf ("%16.16" PRIx64, vma); return nc + printf ("%8.8" PRIx64, vma); =20 + case ZERO_HEX: + if (is_32bit_elf) + return printf ("%08" PRIx64, vma); + return printf ("%016" PRIx64, vma); + =20 case DEC_5: if (vma <=3D 99999) return printf ("%5" PRId64, vma); @@ -1109,6 +1115,26 @@ find_section_by_type (Filedata * filedata, unsigned = int type) return NULL; } =20 +static Elf_Internal_Shdr * +find_section_by_name (Filedata * filedata, const char * name) +{ + unsigned int i; + + if (filedata->section_headers =3D=3D NULL || filedata->string_table_leng= th =3D=3D 0) + return NULL; + + for (i =3D 0; i < filedata->file_header.e_shnum; i++) + { + Elf_Internal_Shdr *sec =3D filedata->section_headers + i; + + if (sec->sh_name < filedata->string_table_length + && streq (name, filedata->string_table + sec->sh_name)) + return sec; + } + + return NULL; +} + /* Return a pointer to section NAME, or NULL if no such section exists, restricted to the list of sections given in SET. */ =20 @@ -1467,76 +1493,6 @@ slurp_rel_relocs (Filedata *filedata, return true; } =20 -static bool -slurp_relr_relocs (Filedata *filedata, - uint64_t relr_offset, - uint64_t relr_size, - uint64_t **relrsp, - uint64_t *nrelrsp) -{ - void *relrs; - size_t size =3D 0, nentries, i; - uint64_t base =3D 0, addr, entry; - - relrs =3D get_data (NULL, filedata, relr_offset, 1, relr_size, - _("RELR relocation data")); - if (!relrs) - return false; - - if (is_32bit_elf) - nentries =3D relr_size / sizeof (Elf32_External_Relr); - else - nentries =3D relr_size / sizeof (Elf64_External_Relr); - for (i =3D 0; i < nentries; i++) - { - if (is_32bit_elf) - entry =3D BYTE_GET (((Elf32_External_Relr *)relrs)[i].r_data); - else - entry =3D BYTE_GET (((Elf64_External_Relr *)relrs)[i].r_data); - if ((entry & 1) =3D=3D 0) - size++; - else - while ((entry >>=3D 1) !=3D 0) - if ((entry & 1) =3D=3D 1) - size++; - } - - *relrsp =3D malloc (size * sizeof (**relrsp)); - if (*relrsp =3D=3D NULL) - { - free (relrs); - error (_("out of memory parsing relocs\n")); - return false; - } - - size =3D 0; - for (i =3D 0; i < nentries; i++) - { - const uint64_t entry_bytes =3D is_32bit_elf ? 4 : 8; - - if (is_32bit_elf) - entry =3D BYTE_GET (((Elf32_External_Relr *)relrs)[i].r_data); - else - entry =3D BYTE_GET (((Elf64_External_Relr *)relrs)[i].r_data); - if ((entry & 1) =3D=3D 0) - { - (*relrsp)[size++] =3D entry; - base =3D entry + entry_bytes; - } - else - { - for (addr =3D base; (entry >>=3D 1) !=3D 0; addr +=3D entry_bytes) - if ((entry & 1) !=3D 0) - (*relrsp)[size++] =3D addr; - base +=3D entry_bytes * (entry_bytes * CHAR_BIT - 1); - } - } - - *nrelrsp =3D size; - free (relrs); - return true; -} - /* Returns the reloc type extracted from the reloc info field. */ =20 static unsigned int @@ -1578,19 +1534,227 @@ uses_msp430x_relocs (Filedata * filedata) || (filedata->file_header.e_ident[EI_OSABI] =3D=3D ELFOSABI_NONE)); } =20 + +static const char * +get_symbol_at (Elf_Internal_Sym * symtab, + uint64_t nsyms, + char * strtab, + uint64_t strtablen, + uint64_t where, + uint64_t * offset_return) +{ + Elf_Internal_Sym * beg =3D symtab; + Elf_Internal_Sym * end =3D symtab + nsyms; + Elf_Internal_Sym * best =3D NULL; + uint64_t dist =3D 0x100000; + + /* FIXME: Since this function is likely to be called repeatedly with + slightly increasing addresses each time, we could speed things up by + caching the last returned value and starting our search from there. = */ + while (beg < end) + { + Elf_Internal_Sym * sym; + uint64_t value; + + sym =3D beg + (end - beg) / 2; + + value =3D sym->st_value; + + if (sym->st_name !=3D 0 + && where >=3D value + && where - value < dist) + { + best =3D sym; + dist =3D where - value; + if (dist =3D=3D 0) + break; + } + + if (where < value) + end =3D sym; + else + beg =3D sym + 1; + } + + if (best =3D=3D NULL) + return NULL; + + if (best->st_name >=3D strtablen) + return NULL; + + if (offset_return !=3D NULL) + * offset_return =3D dist; + + return strtab + best->st_name; +} + +static void +print_relr_addr_and_sym (Elf_Internal_Sym * symtab, + uint64_t nsyms, + char * strtab, + uint64_t strtablen, + uint64_t where) +{ + const char * symname =3D NULL; + uint64_t offset =3D 0; + + print_vma (where, ZERO_HEX); + printf (" "); + + symname =3D get_symbol_at (symtab, nsyms, strtab, strtablen, where, & of= fset); + + if (symname =3D=3D NULL) + printf (""); + else if (offset =3D=3D 0) + print_symbol_name (38, symname); + else + { + print_symbol_name (28, symname); + printf (" + "); + print_vma (offset, PREFIX_HEX); + } +} + +static /* signed */ int +symcmp (const void *p, const void *q) +{ + Elf_Internal_Sym *sp =3D (Elf_Internal_Sym *) p; + Elf_Internal_Sym *sq =3D (Elf_Internal_Sym *) q; + + return sp->st_value > sq->st_value ? 1 : (sp->st_value < sq->st_value ? = -1 : 0); +} + +static bool +dump_relr_relocations (Filedata * filedata, + Elf_Internal_Shdr * section, + Elf_Internal_Sym * symtab, + uint64_t nsyms, + char * strtab, + uint64_t strtablen) +{ + uint64_t * relrs; + uint64_t nentries, i; + uint64_t relr_size =3D section->sh_size; + int relr_entsize =3D section->sh_entsize; + uint64_t relr_offset =3D section->sh_offset; + uint64_t where =3D 0; + int num_bits_in_entry; + + relrs =3D get_data (NULL, filedata, relr_offset, 1, relr_size, _("RELR r= elocation data")); + if (relrs =3D=3D NULL) + return false; + + if (relr_entsize =3D=3D 0) + relr_entsize =3D is_32bit_elf ? 4 : 8; + + nentries =3D relr_size / relr_entsize; + + if (relr_entsize =3D=3D sizeof (Elf32_External_Relr)) + num_bits_in_entry =3D 31; + else if (relr_entsize =3D=3D sizeof (Elf64_External_Relr)) + num_bits_in_entry =3D 63; + else + { + warn (_("Unexpected entsize for RELR section\n")); + return false; + } + =20 + /* Symbol tables are not sorted on address, but we want a quick lookup + for the symbol associated with each address computed below, so sort + the table now. FIXME: This assumes that the symbol table will not + be used later on for some other purpose. */ + qsort (symtab, nsyms, sizeof (Elf_Internal_Sym), symcmp); + + if (do_wide) + { + if (relr_entsize =3D=3D 4) + printf (_("Index: Entry: Address Symbolic Address Notes\n")); + else + printf (_("Index: Entry: Address relocated Symbolic Address = Notes\n")); + } + else + { + if (relr_entsize =3D=3D 4) + printf (_("Index: Entry: Address Symbolic Address\n")); + else + printf (_("Index: Entry: Address relocated Symbolic Address\n")= ); + } + + for (i =3D 0; i < nentries; i++) + { + uint64_t entry; + + if (relr_entsize =3D=3D 4) + entry =3D BYTE_GET (((Elf32_External_Relr *)relrs)[i].r_data); + else + entry =3D BYTE_GET (((Elf64_External_Relr *)relrs)[i].r_data); + + /* We assume that there will never be more than 9999 entries. */ + printf (_("%04u: "), (unsigned int) i); + print_vma (entry, ZERO_HEX); + printf (" "); + + if ((entry & 1) =3D=3D 0) + { + where =3D entry; + print_relr_addr_and_sym (symtab, nsyms, strtab, strtablen, where); + if (do_wide) + printf (_(" (new starting address)")); + printf ("\n"); + where +=3D relr_entsize; + } + else + { + bool first =3D true; + int j; + + /* The least significant bit is ignored. */ + if (entry =3D=3D 1) + warn (_("Malformed RELR bitmap - no significant bits are set\n")); + else if (i =3D=3D 0) + warn (_("Unusual RELR bitmap - no previous entry to set the base addr= ess\n")); + + for (j =3D 0; entry >>=3D 1; j++) + if ((entry & 1) =3D=3D 1) + { + uint64_t addr =3D where + (j * relr_entsize); + =09 + if (first) + { + print_relr_addr_and_sym (symtab, nsyms, strtab, strtablen, addr); + if (do_wide) + printf (_(" (start of bitmap)")); + first =3D false; + } + else + { + printf (_("\n%*s "), relr_entsize =3D=3D 4 ? 15 : 23, " "); + print_relr_addr_and_sym (symtab, nsyms, strtab, strtablen, addr); + } + } + + printf ("\n"); + where +=3D num_bits_in_entry * relr_entsize; + } + } + + free (relrs); + return true; +} + =20 /* Display the contents of the relocation data found at the specified offset. */ =20 static bool -dump_relocations (Filedata *filedata, - uint64_t rel_offset, - uint64_t rel_size, - Elf_Internal_Sym *symtab, - uint64_t nsyms, - char *strtab, - uint64_t strtablen, - relocation_type rel_type, - bool is_dynsym) +dump_relocations (Filedata * filedata, + uint64_t rel_offset, + uint64_t rel_size, + Elf_Internal_Sym * symtab, + uint64_t nsyms, + char * strtab, + uint64_t strtablen, + relocation_type rel_type, + bool is_dynsym) { size_t i; Elf_Internal_Rela * rels; @@ -1611,21 +1775,8 @@ dump_relocations (Filedata *filedata, } else if (rel_type =3D=3D reltype_relr) { - uint64_t * relrs; - const char *format - =3D is_32bit_elf ? "%08" PRIx64 "\n" : "%016" PRIx64 "\n"; - - if (!slurp_relr_relocs (filedata, rel_offset, rel_size, &relrs, - &rel_size)) - return false; - - printf (ngettext (" %" PRIu64 " offset\n", - " %" PRIu64 " offsets\n", rel_size), - rel_size); - for (i =3D 0; i < rel_size; i++) - printf (format, relrs[i]); - free (relrs); - return true; + /* This should have been handled by display_relocations(). */ + return false; } =20 if (is_32bit_elf) @@ -7996,6 +8147,7 @@ process_section_headers (Filedata * filedata) switch (section->sh_type) { case SHT_REL: + case SHT_RELR: case SHT_RELA: if (section->sh_link =3D=3D 0 && (filedata->file_header.e_type =3D=3D ET_EXEC @@ -8349,9 +8501,12 @@ process_section_headers (Filedata * filedata) } =20 static bool -get_symtab (Filedata *filedata, Elf_Internal_Shdr *symsec, - Elf_Internal_Sym **symtab, uint64_t *nsyms, - char **strtab, uint64_t *strtablen) +get_symtab (Filedata * filedata, + Elf_Internal_Shdr * symsec, + Elf_Internal_Sym ** symtab, + uint64_t * nsyms, + char ** strtab, + uint64_t * strtablen) { *strtab =3D NULL; *strtablen =3D 0; @@ -8912,9 +9067,9 @@ static bool display_relocations (Elf_Internal_Shdr * section, Filedata * filedata) { - if (section->sh_type !=3D SHT_RELA - && section->sh_type !=3D SHT_REL - && section->sh_type !=3D SHT_RELR) + relocation_type rel_type =3D rel_type_from_sh_type (section->sh_type); + + if (rel_type =3D=3D reltype_unknown) return false; =20 uint64_t rel_size =3D section->sh_size; @@ -8943,33 +9098,43 @@ display_relocations (Elf_Internal_Shdr * section, num_rela), rel_offset, num_rela); =20 - relocation_type rel_type =3D rel_type_from_sh_type (section->sh_type); + Elf_Internal_Shdr * symsec; + Elf_Internal_Sym * symtab =3D NULL; + uint64_t nsyms =3D 0; + uint64_t strtablen =3D 0; + char * strtab =3D NULL; =20 if (section->sh_link =3D=3D 0 || section->sh_link >=3D filedata->file_header.e_shnum) - /* Symbol data not available. */ - return dump_relocations (filedata, rel_offset, rel_size, - NULL, 0, NULL, 0, rel_type, - false /* is_dynamic */); - =20 - Elf_Internal_Shdr * symsec =3D filedata->section_headers + section->sh_l= ink; - - if (symsec->sh_type !=3D SHT_SYMTAB - && symsec->sh_type !=3D SHT_DYNSYM) - return false; + { + /* Symbol data not available. + This can happen, especially with RELR relocs. + See if there is a .symtab section present. + If so then use it. */ + symsec =3D find_section_by_name (filedata, ".symtab"); + } + else + { + symsec =3D filedata->section_headers + section->sh_link; =20 - Elf_Internal_Sym * symtab; - uint64_t nsyms; - uint64_t strtablen =3D 0; - char * strtab =3D NULL; + if (symsec->sh_type !=3D SHT_SYMTAB + && symsec->sh_type !=3D SHT_DYNSYM) + return false; + } =20 - if (!get_symtab (filedata, symsec, &symtab, &nsyms, &strtab, &strtablen)) + if (symsec !=3D NULL + && !get_symtab (filedata, symsec, &symtab, &nsyms, &strtab, &strtabl= en)) return false; =20 - bool res =3D dump_relocations (filedata, rel_offset, rel_size, - symtab, nsyms, strtab, strtablen, - rel_type, - symsec->sh_type =3D=3D SHT_DYNSYM); + bool res; + + if (rel_type =3D=3D reltype_relr) + res =3D dump_relr_relocations (filedata, section, symtab, nsyms, strta= b, strtablen); + else + res =3D dump_relocations (filedata, rel_offset, rel_size, + symtab, nsyms, strtab, strtablen, + rel_type, + symsec =3D=3D NULL ? false : symsec->sh_type =3D=3D SHT_DYNSYM); free (strtab); free (symtab); =20 @@ -9173,15 +9338,6 @@ find_symbol_for_address (Filedata *filedata, *offset =3D addr.offset; } =20 -static /* signed */ int -symcmp (const void *p, const void *q) -{ - Elf_Internal_Sym *sp =3D (Elf_Internal_Sym *) p; - Elf_Internal_Sym *sq =3D (Elf_Internal_Sym *) q; - - return sp->st_value > sq->st_value ? 1 : (sp->st_value < sq->st_value ? = -1 : 0); -} - /* Process the unwind section. */ =20 #include "unwind-ia64.h" diff --git a/binutils/testsuite/binutils-all/readelf.exp b/binutils/testsui= te/binutils-all/readelf.exp index b91134b4326..09ed75f8761 100644 --- a/binutils/testsuite/binutils-all/readelf.exp +++ b/binutils/testsuite/binutils-all/readelf.exp @@ -642,3 +642,70 @@ readelf_test {-j .rela.debug_info --display-section=3D= .rel.debug_info} $tempfile d readelf_test --display-section=3D0 $tempfile display-section.0 =20 =20 +# Test that RELR relocations are display correctly. +proc readelf_relr_test {} { + global srcdir + global subdir + global READELF + global READELFFLAGS + =20 + set testname "readelf -r (RELR)" + + # Assemble the RELR test file (using magic to work for both 32-bit and + # 64-bit targets). + if {![binutils_assemble $srcdir/$subdir/relr.s tmpdir/relr.o]} then { + unsupported "$testname: failed to assemble RELR test file" + return + } + + # Download it. + set tempfile [remote_download host tmpdir/relr.o] + + # Run "readelf -r" on it. + set got [remote_exec host "$READELF $READELFFLAGS -r $tempfile" "" "/d= ev/null" "readelf.out"] + set got [lindex $got 1] + + # Upload the results. + set output [remote_upload host readelf.out] + + # Check for something going wrong. + if ![string match "" $got] then { + fail "$testname: unexpected output" + send_log $got + send_log "\n" + return + } + + # Search for strings that should be in the output. + # There will also be these strings: + # readelf: Error: Section 4 has invalid sh_entsize of 0 + # readelf: Error: (Using the expected size of 8 for the rest of this= dump) + # But we ignore them... + + set sought { + "0000: 0+01000 0+01000 .*" + "0001: 0+00003 0+0100. .*" + } + + foreach looked_for $sought { + set lines [grep $output $looked_for] + if ![llength $lines] then { + fail "$testname: missing: $looked_for" + send_log readelf.out + return + } + } + + file_on_host delete $tempfile + file_on_host delete $output + + # All done. + pass "$testname" +} + +# The AVR, H8300, IP2K and Z80 targets' .dc.a pseudo-op creates a +# 16-bit entry rather than a 32-bit entry. Thus creating an +# invalid RELR relocation. +setup_xfail "avr-*-*" "h8300-*-*" "ip2k-*-*" "z80-*-*" + +readelf_relr_test diff --git a/binutils/testsuite/binutils-all/relr.s b/binutils/testsuite/bi= nutils-all/relr.s new file mode 100644 index 00000000000..ca9f7dd1174 --- /dev/null +++ b/binutils/testsuite/binutils-all/relr.s @@ -0,0 +1,13 @@ + +# Note - in theory we should set the entsize field. But since +# we want this file to be assembled for both 32-bit and 64-bit +# targets we leave it empty. Readelf will complain, but will +# carry on and (helpfully) it will set the entsize field for us. +# +# We also use the magic .dc.a pseudo-op set the correctly sized +# entries in the RELR array. This works for most, but not all +# ELF based targets. +=09 + .section .relr.foo, "a", %19 + .dc.a 0x1000 + .dc.a 0x0003 diff --git a/ld/testsuite/ld-elf/dt-relr-2b.d b/ld/testsuite/ld-elf/dt-relr= -2b.d index b1391566a13..48a3eb7f15c 100644 --- a/ld/testsuite/ld-elf/dt-relr-2b.d +++ b/ld/testsuite/ld-elf/dt-relr-2b.d @@ -13,5 +13,9 @@ Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+= contains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_.*_(RELATIVE|UADDR.*) .* #... Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: - 4 offsets +#... +0000: +[0-9a-f]+ [0-9a-f]+ +data \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +data \+ 0x[0-9a-f]+ \(start of bitmap\) + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ #pass diff --git a/ld/testsuite/ld-elf/dt-relr-2c.d b/ld/testsuite/ld-elf/dt-relr= -2c.d index c285e8707d7..7f6383b0184 100644 --- a/ld/testsuite/ld-elf/dt-relr-2c.d +++ b/ld/testsuite/ld-elf/dt-relr-2c.d @@ -13,5 +13,8 @@ Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+= contains 2 entries: [0-9a-f]+ +[0-9a-f]+ +R_.*_(RELATIVE|UADDR.*) .* #... Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: - 3 offsets +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #pass diff --git a/ld/testsuite/ld-elf/dt-relr-2d.d b/ld/testsuite/ld-elf/dt-relr= -2d.d index 7fd3046a1cf..f1184fefeb2 100644 --- a/ld/testsuite/ld-elf/dt-relr-2d.d +++ b/ld/testsuite/ld-elf/dt-relr-2d.d @@ -13,5 +13,9 @@ Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+= contains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_.*_(RELATIVE|UADDR.*) .* #... Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: - 4 offsets +#... +0000: +[0-9a-f]+ [0-9a-f]+ +data \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +data \+ 0x[0-9a-f]+ \(start of bitmap\) + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ #pass diff --git a/ld/testsuite/ld-elf/dt-relr-2e.d b/ld/testsuite/ld-elf/dt-relr= -2e.d index cdff8465a57..eddb5e3d14e 100644 --- a/ld/testsuite/ld-elf/dt-relr-2e.d +++ b/ld/testsuite/ld-elf/dt-relr-2e.d @@ -13,5 +13,9 @@ Relocation section '\.rel(a|)\.data' at offset 0x[0-9a-f]= + contains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_.*_(RELATIVE|UADDR.*) .* #... Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: - 4 offsets +#... +0000: +[0-9a-f]+ [0-9a-f]+ +data \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +data \+ 0x[0-9a-f]+ \(start of bitmap\) + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ #pass diff --git a/ld/testsuite/ld-elf/dt-relr-2i.d b/ld/testsuite/ld-elf/dt-relr= -2i.d index ed0ef9ccded..55e8c256b92 100644 --- a/ld/testsuite/ld-elf/dt-relr-2i.d +++ b/ld/testsuite/ld-elf/dt-relr-2i.d @@ -13,5 +13,9 @@ Relocation section '\.rel(a|)\.dyn' at offset 0x[0-9a-f]+= contains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_.*_(RELATIVE|UADDR.*) .* #... Relocation section '\.relr\.dyn' at offset 0x[0-9a-f]+ contains 2 entries: - 4 offsets +#... +0000: +[0-9a-f]+ [0-9a-f]+ +data \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +data \+ 0x[0-9a-f]+ \(start of bitmap\) + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ + +[0-9a-f]+ +data \+ 0x[0-9a-f]+ #pass diff --git a/ld/testsuite/ld-i386/dt-relr-1a.d b/ld/testsuite/ld-i386/dt-re= lr-1a.d index cbb8ab6158b..3944911e4f7 100644 --- a/ld/testsuite/ld-i386/dt-relr-1a.d +++ b/ld/testsuite/ld-i386/dt-relr-1a.d @@ -14,11 +14,10 @@ Relocation section '\.rel\.plt' at offset 0x[0-9a-f]+ c= ontains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func1 =20 Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries: - +3 offsets -[a-f0-9]+ -[a-f0-9]+ -[a-f0-9]+ - +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #... Symbol table '.symtab' contains [0-9]+ entries: Num: Value Size Type Bind Vis Ndx Name diff --git a/ld/testsuite/ld-i386/dt-relr-1b.d b/ld/testsuite/ld-i386/dt-re= lr-1b.d index 3dd988158c6..947d8354b23 100644 --- a/ld/testsuite/ld-i386/dt-relr-1b.d +++ b/ld/testsuite/ld-i386/dt-relr-1b.d @@ -17,11 +17,10 @@ Relocation section '\.rel\.plt' at offset 0x[0-9a-f]+ c= ontains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_386_JUMP_SLOT +0+ +func1 =20 Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries: - +3 offsets -[a-f0-9]+ -[a-f0-9]+ -[a-f0-9]+ - +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #... Symbol table '.symtab' contains [0-9]+ entries: Num: Value Size Type Bind Vis Ndx Name diff --git a/ld/testsuite/ld-powerpc/abs-pie-relr.r b/ld/testsuite/ld-power= pc/abs-pie-relr.r index 22effe89541..049cd7aa983 100644 --- a/ld/testsuite/ld-powerpc/abs-pie-relr.r +++ b/ld/testsuite/ld-powerpc/abs-pie-relr.r @@ -4,5 +4,5 @@ #readelf: -rW =20 Relocation section '\.relr\.dyn' at offset .* contains 1 entry: - 1 offset -0+10338 +Index: Entry: +Address relocated Symbolic Address +Notes +0000: +[0-9a-f]+ [0-9a-f]+ +x \(new starting address\) diff --git a/ld/testsuite/ld-powerpc/abs-shared-relr.r b/ld/testsuite/ld-po= werpc/abs-shared-relr.r index 978c43a38e9..3ce70f740e2 100644 --- a/ld/testsuite/ld-powerpc/abs-shared-relr.r +++ b/ld/testsuite/ld-powerpc/abs-shared-relr.r @@ -13,5 +13,6 @@ Relocation section '\.rela\.dyn' at offset .* contains 6 = entries: 0+10450 0+400000026 R_PPC64_ADDR64 123456789abcdef0 c \+ 0 =20 Relocation section '\.relr\.dyn' at offset .* contains 1 entry: - 1 offset -0+10438 +Index: Entry: +Address relocated Symbolic Address +Notes +0000: +[0-9a-f]+ [0-9a-f]+ +x \(new starting address\) + diff --git a/ld/testsuite/ld-x86-64/dt-relr-1a-x32.d b/ld/testsuite/ld-x86-= 64/dt-relr-1a-x32.d index 8f2f6fc2f74..78ffda9ce15 100644 --- a/ld/testsuite/ld-x86-64/dt-relr-1a-x32.d +++ b/ld/testsuite/ld-x86-64/dt-relr-1a-x32.d @@ -14,11 +14,10 @@ Relocation section '.rela.plt' at offset 0x[0-9a-f]+ co= ntains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0 =20 Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries: - +3 offsets -[a-f0-9]+ -[a-f0-9]+ -[a-f0-9]+ - +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #... Symbol table '.symtab' contains [0-9]+ entries: +Num: +Value +Size Type +Bind +Vis +Ndx Name diff --git a/ld/testsuite/ld-x86-64/dt-relr-1a.d b/ld/testsuite/ld-x86-64/d= t-relr-1a.d index 218594dfb98..8e099257037 100644 --- a/ld/testsuite/ld-x86-64/dt-relr-1a.d +++ b/ld/testsuite/ld-x86-64/dt-relr-1a.d @@ -14,11 +14,10 @@ Relocation section '.rela.plt' at offset 0x[0-9a-f]+ co= ntains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0 =20 Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries: - +3 offsets -[a-f0-9]+ -[a-f0-9]+ -[a-f0-9]+ - +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #... Symbol table '.symtab' contains [0-9]+ entries: +Num: +Value +Size Type +Bind +Vis +Ndx Name diff --git a/ld/testsuite/ld-x86-64/dt-relr-1b-x32.d b/ld/testsuite/ld-x86-= 64/dt-relr-1b-x32.d index 0ddffc82429..c2e3a3a931f 100644 --- a/ld/testsuite/ld-x86-64/dt-relr-1b-x32.d +++ b/ld/testsuite/ld-x86-64/dt-relr-1b-x32.d @@ -17,11 +17,10 @@ Relocation section '.rela.plt' at offset 0x[0-9a-f]+ co= ntains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0 =20 Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries: - +3 offsets -[a-f0-9]+ -[a-f0-9]+ -[a-f0-9]+ - +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #... Symbol table '.symtab' contains [0-9]+ entries: +Num: +Value +Size Type +Bind +Vis +Ndx Name diff --git a/ld/testsuite/ld-x86-64/dt-relr-1b.d b/ld/testsuite/ld-x86-64/d= t-relr-1b.d index 4e462dd1fcb..03e0202fe81 100644 --- a/ld/testsuite/ld-x86-64/dt-relr-1b.d +++ b/ld/testsuite/ld-x86-64/dt-relr-1b.d @@ -17,11 +17,10 @@ Relocation section '.rela.plt' at offset 0x[0-9a-f]+ co= ntains 1 entry: [0-9a-f]+ +[0-9a-f]+ +R_X86_64_JUMP_SLOT +0+ +func1 \+ 0 =20 Relocation section '.relr.dyn' at offset 0x[a-f0-9]+ contains 2 entries: - +3 offsets -[a-f0-9]+ -[a-f0-9]+ -[a-f0-9]+ - +#... +0000: +[0-9a-f]+ [0-9a-f]+ +.* \(new starting address\) +0001: +[0-9a-f]+ [0-9a-f]+ +.* \(start of bitmap\) + +[0-9a-f]+ +.* #... Symbol table '.symtab' contains [0-9]+ entries: +Num: +Value +Size Type +Bind +Vis +Ndx Name