This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Handle PowerPC64 ELFv1 function descriptors in libbacktrace (PR other/82368)
- From: Szabolcs Nagy <szabolcs dot nagy at arm dot com>
- To: Jakub Jelinek <jakub at redhat dot com>, Ian Lance Taylor <iant at golang dot org>, Segher Boessenkool <segher at kernel dot crashing dot org>, David Edelsohn <dje dot gcc at gmail dot com>, Alan Modra <amodra at gmail dot com>
- Cc: nd at arm dot com, gcc-patches at gcc dot gnu dot org
- Date: Thu, 15 Feb 2018 11:08:20 +0000
- Subject: Re: [PATCH] Handle PowerPC64 ELFv1 function descriptors in libbacktrace (PR other/82368)
- Authentication-results: sourceware.org; auth=none
- Authentication-results: spf=none (sender IP is ) smtp.mailfrom=Szabolcs dot Nagy at arm dot com;
- Nodisclaimer: True
- References: <20180214114138.GX5867@tucnak>
- Spamdiagnosticmetadata: NSPM
- Spamdiagnosticoutput: 1:99
On 14/02/18 11:41, Jakub Jelinek wrote:
Hi!
As mentioned in detail in the PR, PowerPC64 ELFv1 function symbols
point to function descriptors in .opd section rather than actual
code, and one needs to read the code address from the .opd section
in order to associate symbols with .text addresses.
Fixed thusly, bootstrapped/regtested on powerpc64-linux (-m32/-m64
testing) and powerpc64le-linux, ok for trunk?
2018-02-14 Jakub Jelinek <jakub@redhat.com>
PR other/82368
* elf.c (EM_PPC64, EF_PPC64_ABI): Undefine and define.
(struct elf_ppc64_opd_data): New type.
(elf_initialize_syminfo): Add opd argument, handle symbols
pointing into the PowerPC64 ELFv1 .opd section.
(elf_add): Read .opd section on PowerPC64 ELFv1, pass pointer
to structure with .opd data to elf_initialize_syminfo.
--- libbacktrace/elf.c.jj 2018-02-08 20:46:10.671242369 +0000
+++ libbacktrace/elf.c 2018-02-14 08:39:06.674088951 +0000
...
@@ -2857,6 +2889,23 @@ elf_add (struct backtrace_state *state,
debuglink_crc = *(const uint32_t*)(debuglink_data + crc_offset);
}
}
+
+ /* Read the .opd section on PowerPC64 ELFv1. */
+ if (ehdr.e_machine == EM_PPC64
+ && (ehdr.e_flags & EF_PPC64_ABI) < 2
+ && shdr->sh_type == SHT_PROGBITS
this broke baremetal arm targets (e.g. aarch64-none-elf with newlib)
...src/gcc/libbacktrace/elf.c: In function 'elf_add':
...src/gcc/libbacktrace/elf.c:2896:24: error: 'SHT_PROGBITS' undeclared (first use in this function)
&& shdr->sh_type == SHT_PROGBITS
^~~~~~~~~~~~
+ && strcmp (name, ".opd") == 0)
+ {
+ if (!backtrace_get_view (state, descriptor, shdr->sh_offset,
+ shdr->sh_size, error_callback, data,
+ &opd_data.view))
+ goto fail;
+
+ opd = &opd_data;
+ opd->addr = shdr->sh_addr;
+ opd->data = (const char *) opd_data.view.data;
+ opd->size = shdr->sh_size;
+ }
}
if (symtab_shndx == 0)