mirror of
https://github.com/apache/nuttx.git
synced 2026-10-03 20:27:53 +00:00
tools/nxflat: Leave ARM unwind tables out of an NXFLAT module.
CONFIG_UNWINDER_ARM compiles everything with -funwind-tables, modules included, so each module carries .ARM.exidx and .ARM.extab. The NXFLAT link scripts do not name them, and ldnxflat placed them in D-Space, where the first R_ARM_PREL31 entry stopped the conversion: ldnxflat: arm relocation 42 at D-Space 00000018 is not handled That relocation cannot be handled: an exidx entry is an offset from itself to a function in I-Space, and the distance between the two segments is only known when the loader places them. Nothing unwinds through a module either, since the unwinder only reads the firmware's own table. So ldnxflat leaves both sections out of the images, and with them the relocations against them, as it already does for sections it does not place. A module without unwind tables converts exactly as before. On mps3-an547:nsh under QEMU with CONFIG_UNWINDER_ARM and examples/nxflat, the modules failed to convert; now they convert and errno, hello, mutex, pthread and struct run. The eleven modules of tools/nxflat/testsuite.sh convert to the same bytes as before. Assisted-by: Claude Code:claude-opus-5-5 Signed-off-by: Marco Casaroli <marco.casaroli@gmail.com>
This commit is contained in:
parent
317bfcf67c
commit
295f0e373c
1 changed files with 9 additions and 1 deletions
|
|
@ -193,6 +193,7 @@ static struct elf32_shdr_s *g_shdr;
|
|||
static struct elf32_sym_s *g_syms;
|
||||
static size_t g_nsyms;
|
||||
static const char *g_strtab;
|
||||
static const char *g_shstrtab;
|
||||
static enum segment_e *g_segof; /* Per section */
|
||||
|
||||
static const struct nxflat_arch_s *g_arch;
|
||||
|
|
@ -279,6 +280,7 @@ static void read_elf(void)
|
|||
g_syms = elf.syms;
|
||||
g_nsyms = elf.nsyms;
|
||||
g_strtab = elf.strtab;
|
||||
g_shstrtab = elf.shstrtab;
|
||||
|
||||
if (g_ehdr->e_type != ET_REL)
|
||||
{
|
||||
|
|
@ -311,6 +313,10 @@ static void read_elf(void)
|
|||
* Executable is I-Space; everything else allocated is D-Space, read-only
|
||||
* data included, because the model reaches that through the GOT.
|
||||
*
|
||||
* ARM unwind tables are left out. Their entries are PC-relative from
|
||||
* D-Space into I-Space, which the container cannot express, and nothing
|
||||
* unwinds through a module.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
static void place_sections(void)
|
||||
|
|
@ -330,7 +336,9 @@ static void place_sections(void)
|
|||
struct elf32_shdr_s *s = &g_shdr[i];
|
||||
uint32_t end = s->sh_addr + s->sh_size;
|
||||
|
||||
if ((s->sh_flags & SHF_ALLOC) == 0)
|
||||
if ((s->sh_flags & SHF_ALLOC) == 0 ||
|
||||
strncmp(g_shstrtab + s->sh_name, ".ARM.exidx", 10) == 0 ||
|
||||
strncmp(g_shstrtab + s->sh_name, ".ARM.extab", 10) == 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue