mirror of
https://github.com/PX4/PX4-Autopilot.git
synced 2026-05-30 16:32:13 +08:00
Rename elf.h to elf32.h; Additional ELF loader changes
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5263 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -344,6 +344,14 @@ examples/elf
|
|||||||
If you really want to do this, you can create a NuttX x86 buildroot toolchain
|
If you really want to do this, you can create a NuttX x86 buildroot toolchain
|
||||||
and use that be build the ELF executables for the ROMFS file system.
|
and use that be build the ELF executables for the ROMFS file system.
|
||||||
|
|
||||||
|
5. Linker scripts. You might also want to use a linker scripts to combine
|
||||||
|
sections better. An example linker script is at nuttx/binfmt/libelf/gnu-elf.ld.
|
||||||
|
That example might have to be tuned for your particular linker output to
|
||||||
|
position additional sections correctly. The GNU LD LDELFFLAGS then might
|
||||||
|
be:
|
||||||
|
|
||||||
|
LDELFFLAGS = -r -e main -T$(TOPDIR)/binfmt/libelf/gnu-elf.ld
|
||||||
|
|
||||||
examples/ftpc
|
examples/ftpc
|
||||||
^^^^^^^^^^^^^
|
^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ int elf_main(int argc, char *argv[])
|
|||||||
/* Create a ROM disk for the ROMFS filesystem */
|
/* Create a ROM disk for the ROMFS filesystem */
|
||||||
|
|
||||||
message("Registering romdisk at /dev/ram%d\n", CONFIG_EXAMPLES_ELF_DEVMINOR);
|
message("Registering romdisk at /dev/ram%d\n", CONFIG_EXAMPLES_ELF_DEVMINOR);
|
||||||
ret = romdisk_register(CONFIG_EXAMPLES_ELF_DEVMINOR, romfs_img,
|
ret = romdisk_register(CONFIG_EXAMPLES_ELF_DEVMINOR, (FAR uint8_t *)romfs_img,
|
||||||
NSECTORS(romfs_img_len), SECTORSIZE);
|
NSECTORS(romfs_img_len), SECTORSIZE);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -167,7 +167,7 @@ int nxflat_main(int argc, char *argv[])
|
|||||||
/* Create a ROM disk for the ROMFS filesystem */
|
/* Create a ROM disk for the ROMFS filesystem */
|
||||||
|
|
||||||
message("Registering romdisk\n");
|
message("Registering romdisk\n");
|
||||||
ret = romdisk_register(0, romfs_img, NSECTORS(romfs_img_len), SECTORSIZE);
|
ret = romdisk_register(0, (FAR uint8_t *)romfs_img, NSECTORS(romfs_img_len), SECTORSIZE);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
{
|
{
|
||||||
err("ERROR: romdisk_register failed: %d\n", ret);
|
err("ERROR: romdisk_register failed: %d\n", ret);
|
||||||
|
|||||||
@@ -3515,4 +3515,6 @@
|
|||||||
include/nuttx/binfmt/.
|
include/nuttx/binfmt/.
|
||||||
* arch/sim/src/up_elf.c and arch/x86/src/common/up_elf.c: Add
|
* arch/sim/src/up_elf.c and arch/x86/src/common/up_elf.c: Add
|
||||||
for ELF modules.
|
for ELF modules.
|
||||||
|
* arch/arm/include/elf.h: Added ARM ELF header file.
|
||||||
|
* include/elf32.h: Renamed elf.h to elf32.h.
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@
|
|||||||
* e_ident[EI_DATA] = ELFDATA2LSB (little endian) or ELFDATA2MSB (big endian)
|
* e_ident[EI_DATA] = ELFDATA2LSB (little endian) or ELFDATA2MSB (big endian)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#if 0 /* Defined in include/elf.h */
|
#if 0 /* Defined in include/elf32.h */
|
||||||
#define EM_ARM 40
|
#define EM_ARM 40
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
|||||||
@@ -40,7 +40,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -42,7 +42,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* examples/elf/gnu-elf-gotoff.ld
|
* examples/elf/gnu-elf.ld
|
||||||
*
|
*
|
||||||
* Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -33,44 +33,11 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
MEMORY
|
|
||||||
{
|
|
||||||
ISPACE : ORIGIN = 0x0, LENGTH = 2097152
|
|
||||||
DSPACE : ORIGIN = 0x0, LENGTH = 2097152
|
|
||||||
}
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* The XFLAT program image is divided into two segments:
|
|
||||||
*
|
|
||||||
* (1) ISpace (Instruction Space). This is the segment that contains
|
|
||||||
* code (.text). Everything in the segment should be fetch-able
|
|
||||||
* machine PC instructions (jump, branch, call, etc.).
|
|
||||||
* (2) DSpace (Data Space). This is the segment that contains both
|
|
||||||
* read-write data (.data, .bss) as well as read-only data (.rodata).
|
|
||||||
* Everything in this segment should be access-able with machine
|
|
||||||
* PIC load and store instructions.
|
|
||||||
*
|
|
||||||
* Older versions of GCC (at least up to GCC 4.3.3), use GOT-relative
|
|
||||||
* addressing to access RO data. In that case, read-only data (.rodata) must
|
|
||||||
* reside in D-Space and this linker script should be used.
|
|
||||||
*
|
|
||||||
* Newer versions of GCC (at least as of GCC 4.6.3), use PC-relative
|
|
||||||
* addressing to access RO data. In that case, read-only data (.rodata) must
|
|
||||||
* reside in I-Space and this linker script should NOT be used with those
|
|
||||||
* newer tools.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
SECTIONS
|
SECTIONS
|
||||||
{
|
{
|
||||||
.text 0x00000000 :
|
.text 0x00000000 :
|
||||||
{
|
{
|
||||||
/* ISpace is located at address 0. Every (unrelocated) ISpace
|
_stext = . ;
|
||||||
* address is an offset from the begining of this segment.
|
|
||||||
*/
|
|
||||||
|
|
||||||
text_start = . ;
|
|
||||||
|
|
||||||
*(.text)
|
*(.text)
|
||||||
*(.text.*)
|
*(.text.*)
|
||||||
*(.gnu.warning)
|
*(.gnu.warning)
|
||||||
@@ -79,57 +46,35 @@ SECTIONS
|
|||||||
*(.glue_7t)
|
*(.glue_7t)
|
||||||
*(.jcr)
|
*(.jcr)
|
||||||
|
|
||||||
/* C++ support: The .init and .fini sections contain XFLAT-
|
/* C++ support: The .init and .fini sections contain specific logic
|
||||||
* specific logic to manage static constructors and destructors.
|
* to manage static constructors and destructors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*(.gnu.linkonce.t.*)
|
*(.gnu.linkonce.t.*)
|
||||||
*(.init)
|
*(.init)
|
||||||
*(.fini)
|
*(.fini)
|
||||||
|
|
||||||
/* This is special code area at the end of the normal
|
|
||||||
text section. It contains a small lookup table at
|
|
||||||
the start followed by the code pointed to by entries
|
|
||||||
in the lookup table. */
|
|
||||||
|
|
||||||
. = ALIGN (4) ;
|
|
||||||
PROVIDE(__ctbp = .);
|
|
||||||
*(.call_table_data)
|
|
||||||
*(.call_table_text)
|
|
||||||
|
|
||||||
_etext = . ;
|
_etext = . ;
|
||||||
|
}
|
||||||
|
|
||||||
} > ISPACE
|
.rodata :
|
||||||
|
|
||||||
/* DSpace is also located at address 0. Every (unrelocated) DSpace
|
|
||||||
* address is an offset from the begining of this segment.
|
|
||||||
*/
|
|
||||||
|
|
||||||
.data 0x00000000 :
|
|
||||||
{
|
{
|
||||||
/* In this model, .rodata is access using PC-relative addressing
|
_srodata = . ;
|
||||||
* and, hence, must also reside in the .text section.
|
|
||||||
*/
|
|
||||||
|
|
||||||
__data_start = . ;
|
|
||||||
*(.rodata)
|
*(.rodata)
|
||||||
*(.rodata1)
|
*(.rodata1)
|
||||||
*(.rodata.*)
|
*(.rodata.*)
|
||||||
*(.gnu.linkonce.r*)
|
*(.gnu.linkonce.r*)
|
||||||
|
_erodata = . ;
|
||||||
|
}
|
||||||
|
|
||||||
|
.data :
|
||||||
|
{
|
||||||
|
_sdata = . ;
|
||||||
*(.data)
|
*(.data)
|
||||||
*(.data1)
|
*(.data1)
|
||||||
*(.data.*)
|
*(.data.*)
|
||||||
*(.gnu.linkonce.d*)
|
*(.gnu.linkonce.d*)
|
||||||
*(.data1)
|
_edata = . ;
|
||||||
*(.eh_frame)
|
}
|
||||||
*(.gcc_except_table)
|
|
||||||
|
|
||||||
*(.gnu.linkonce.s.*)
|
|
||||||
*(__libc_atexit)
|
|
||||||
*(__libc_subinit)
|
|
||||||
*(__libc_subfreeres)
|
|
||||||
*(.note.ABI-tag)
|
|
||||||
|
|
||||||
/* C++ support. For each global and static local C++ object,
|
/* C++ support. For each global and static local C++ object,
|
||||||
* GCC creates a small subroutine to construct the object. Pointers
|
* GCC creates a small subroutine to construct the object. Pointers
|
||||||
@@ -139,39 +84,34 @@ SECTIONS
|
|||||||
* stored in .dtors.
|
* stored in .dtors.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
*(.gnu.linkonce.d.*)
|
.ctors :
|
||||||
|
{
|
||||||
_ctors_start = . ;
|
_sctros = . ;
|
||||||
*(.ctors)
|
*(.ctors)
|
||||||
_ctors_end = . ;
|
_edtors = . ;
|
||||||
_dtors_start = . ;
|
}
|
||||||
*(.dtors)
|
|
||||||
_dtors_end = . ;
|
|
||||||
|
|
||||||
_edata = . ;
|
.ctors :
|
||||||
edata = ALIGN( 0x10 ) ;
|
{
|
||||||
} > DSPACE
|
_sdtors = . ;
|
||||||
|
*(.dtors)
|
||||||
|
_edtors = . ;
|
||||||
|
}
|
||||||
|
|
||||||
.bss :
|
.bss :
|
||||||
{
|
{
|
||||||
__bss_start = _edata ;
|
_sbss = . ;
|
||||||
*(.dynsbss)
|
|
||||||
*(.sbss)
|
|
||||||
*(.sbss.*)
|
|
||||||
*(.scommon)
|
|
||||||
*(.dynbss)
|
|
||||||
*(.bss)
|
*(.bss)
|
||||||
*(.bss.*)
|
*(.bss.*)
|
||||||
*(.bss*)
|
*(.sbss)
|
||||||
|
*(.sbss.*)
|
||||||
*(.gnu.linkonce.b*)
|
*(.gnu.linkonce.b*)
|
||||||
*(COMMON)
|
*(COMMON)
|
||||||
end = ALIGN( 0x10 ) ;
|
_ebss = . ;
|
||||||
_end = ALIGN( 0x10 ) ;
|
}
|
||||||
} > DSPACE
|
|
||||||
|
|
||||||
.got 0 : { *(.got.plt) *(.got) }
|
|
||||||
.junk 0 : { *(.rel*) *(.rela*) }
|
|
||||||
/* Stabs debugging sections. */
|
/* Stabs debugging sections. */
|
||||||
|
|
||||||
.stab 0 : { *(.stab) }
|
.stab 0 : { *(.stab) }
|
||||||
.stabstr 0 : { *(.stabstr) }
|
.stabstr 0 : { *(.stabstr) }
|
||||||
.stab.excl 0 : { *(.stab.excl) }
|
.stab.excl 0 : { *(.stab.excl) }
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <nuttx/config.h>
|
#include <nuttx/config.h>
|
||||||
|
|
||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
|
|
||||||
#include <nuttx/binfmt/elf.h>
|
#include <nuttx/binfmt/elf.h>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
|
|||||||
@@ -41,7 +41,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* include/elf.h
|
* include/elf32.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@@ -36,8 +36,8 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_ELF_H
|
#ifndef __INCLUDE_ELF32_H
|
||||||
#define __INCLUDE_ELF_H
|
#define __INCLUDE_ELF32_H
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@@ -349,4 +349,4 @@ typedef struct
|
|||||||
|
|
||||||
//extern Elf32_Dyn _DYNAMIC[] ;
|
//extern Elf32_Dyn _DYNAMIC[] ;
|
||||||
|
|
||||||
#endif /* __INCLUDE_ELF_H */
|
#endif /* __INCLUDE_ELF32_H */
|
||||||
@@ -45,7 +45,7 @@
|
|||||||
#include <sys/types.h>
|
#include <sys/types.h>
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdbool.h>
|
#include <stdbool.h>
|
||||||
#include <elf.h>
|
#include <elf32.h>
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
|||||||
Reference in New Issue
Block a user