diff --git a/Documentation/applications/examples/nxflatxip/index.rst b/Documentation/applications/examples/nxflatxip/index.rst index f3f2244d9768b..38e3e1c07325f 100644 --- a/Documentation/applications/examples/nxflatxip/index.rst +++ b/Documentation/applications/examples/nxflatxip/index.rst @@ -61,9 +61,9 @@ Building the module =================== The module is built from ``module/xipmod.c`` at build time, exactly the way -:doc:`../nxflat/index` builds its test programs, so it needs the same two -host tools from the NuttX toolchain, ``mknxflat`` and ``ldnxflat``, and the -board's ``Make.defs`` must name them. +:doc:`../nxflat/index` builds its test programs, so it needs the same host +tools: ``mknxflat``, which NuttX builds itself, and ``ldnxflat``, which has +to come from the buildroot toolchain. See :doc:`/components/nxflat`. The module has no static data and no string constants, and reports through a callback into the firmware rather than formatting its own output. The comment diff --git a/Documentation/components/filesystem/nxflat.rst b/Documentation/components/filesystem/nxflat.rst index 6d0b220629518..094b9310793a1 100644 --- a/Documentation/components/filesystem/nxflat.rst +++ b/Documentation/components/filesystem/nxflat.rst @@ -160,14 +160,14 @@ indeed, a solution to the above NXFLAT problem in newer compilers. You simply need to modify the board Make.defs file like: -1. ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 +1. ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r9 .. code-block:: bash - +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -mno-pic-data-is-text-relative + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r9 -mno-pic-data-is-text-relative -NOTE the minor difference from the post: NuttX uses ``r10`` as -the PIC base register by default in all configurations. +NuttX uses ``r9`` as the PIC base register in all configurations, +which matches the register named in the post above. See this `thread `_ for additional information. diff --git a/Documentation/components/nxflat.rst b/Documentation/components/nxflat.rst index 755af04e43177..63c95a29796e9 100644 --- a/Documentation/components/nxflat.rst +++ b/Documentation/components/nxflat.rst @@ -88,8 +88,8 @@ Limitations - **Read-Only Data in RAM**: With older GCC compilers (at least up to 4.3.3), read-only data must reside in RAM. In code generated by GCC, all data references are - indexed by the PIC2 base register (that is usually R10 or sl for the - ARM processors). The includes read-only data (.rodata). Embedded + indexed by the PIC2 base register (r9 for the ARM processors). + The includes read-only data (.rodata). Embedded firmware developers normally like to keep .rodata in FLASH with the code sections. But because all data is referenced with the PIC base register, all of that data must lie in RAM. A NXFLAT @@ -136,35 +136,33 @@ such, NXFLAT is currently in an early alpha phase. NXFLAT Toolchain ================ -Building the NXFLAT Toolchain ------------------------------ - -In order to use NXFLAT, you must use special NXFLAT tools to create the -binary module in FLASH. To do this, you will need to download the -buildroot package and build it on your Linux or Cygwin machine. The -buildroot can be downloaded from -`Bitbucket.org `__. You -will need version 0.1.7 or later. - -Here are some general build instructions: - -- You must have already configured NuttX in ``/nuttx`` -- Download the buildroot package ``buildroot-0.x.y`` into - ```` -- Unpack ``/buildroot-0.x.y.tar.gz`` using a command like ``tar zxf buildroot-0.x.y``. - This will result in a new directory like ``/buildroot-0.x.y`` -- Move this into position: - ``mv /buildroot-0.x.y``\ /buildroot -- ``cd``\ /buildroot +Getting the NXFLAT Tools +------------------------ + +Building an NXFLAT module takes two tools beyond an ordinary GCC toolchain: +``mknxflat``, which generates the module's *thunk* file, and ``ldnxflat``, +which links the module into the NXFLAT binary format. + +``mknxflat`` is part of NuttX, in ``tools/nxflat``. The build produces it as +``tools/mknxflat`` whenever ``CONFIG_NXFLAT`` is selected, so there is +nothing to install. + +``ldnxflat`` is not part of NuttX and has to be built from the buildroot +package, which can be downloaded from +`Bitbucket.org `__. You +will need version 0.1.7 or later: + +- Unpack the package and ``cd`` into the resulting directory. - Copy a configuration file into the top buildroot directory: ``cp boards/abc-defconfig-x.y.z .config``. -- Enable building of the NXFLAT tools by ``make menuconfig``. Select to - build the NXFLAT toolchain with GCC (you can also select omit - building GCC with and only build the NXFLAT toolchain for use with - your own GCC toolchain). -- Make the toolchain: ``make``. When the make completes, the tool - binaries will be available under - ``/buildroot/build_abc/staging_dir/bin`` +- Run ``make menuconfig`` and select the NXFLAT toolchain. Building GCC + can be omitted if you already have a toolchain of your own. +- Run ``make``. The tool binaries are left under + ``build_abc/staging_dir/bin``; put that directory on your ``PATH``. + +On ARM, ``arch/arm/src/common/Toolchain.defs`` provides both ``MKNXFLAT`` +(with the ``-a`` option following ``CONFIG_ARM_THUMB``) and ``LDNXFLAT``, so +a board only has to assign them if it needs something different. mknxflat -------- @@ -172,21 +170,27 @@ mknxflat ``mknxflat`` is used to build a *thunk* file. See below for usage:: - Usage: mknxflat [options] + Usage: mknxflat [options] Where options are one or more of the following. Note - that a space is always required between the option and - any following arguments. + that a space is always required between the + option and any following arguments. + -a + Instruction set of the module: arm or thumb2 + [thumb2] -d Use dynamic symbol table. [symtab] - -f - Take next commands from [cmd-line] -o - Output to [stdout] + Output to [stdout] -v Verbose output [no output] -w Import weakly declared functions, i.e., weakly - declared functions are expected to be provided at - load-time [not imported] + declared functions are expected to be + provided at load-time [not imported] + +A module calls an imported function through one of these thunks, which +reaches the import table using the module's PIC base register. The thunks +are emitted as assembly, so ``-a`` must match the instruction set the module +was compiled for. ldnxflat -------- @@ -263,7 +267,7 @@ example). .. code-block:: makefile hello-thunk.S: hello.r1 - mknxflat -o $@ $^ + $(MKNXFLAT) -o $@ $^ * Target 3: @@ -277,7 +281,7 @@ example). .. code-block:: makefile hello: hello.r2 - ldnxflat -e main -s 2048 -o $@ $^ + $(LDNXFLAT) -e main -s 2048 -o $@ $^ **Target 1**. This target links all of the module's object files together into one relocatable object. Two relocatable objects will be @@ -290,7 +294,7 @@ CFLAGS must be provided. First, the option ``-fpic`` is required to tell the compiler to generate position independent code (other GCC options, like ``-fno-jump-tables`` might also be desirable). For ARM compilers, two additional compilation options are required: ``-msingle-pic-base`` -and ``-mpic-register=r10``. On ARM these are supplied centrally rather +and ``-mpic-register=r9``. On ARM these are supplied centrally rather than per board; see `Where the ARM PIC flags come from`_ below. **Target 2**. Given the ``hello.r1`` relocatable object, this target @@ -331,6 +335,35 @@ object to create the final, NXFLAT module ``hello`` by executing **binfmt Registration** NXFLAT calls :c:func:`register_binfmt` to incorporate itself into the system. +Module ABI marker +----------------- + +The NXFLAT header carries no version field -- ``h_magic`` is written by +``ldnxflat``, which lives outside this repository and cannot be changed in +step with the loader -- so the module ABI is declared through the import +table instead. Every module built by ``mknxflat`` imports the symbol +``__nxflat_abi_v2``, the base firmware defines it, and the loader refuses a +module whose import table does not name it. The generation is bumped +whenever the module ABI changes; v2 is the move of the PIC base register to +r9, and a v1 module's thunks would add r10 and branch to a wild address on +the first call into the base firmware. + +A module built before the marker therefore fails ``exec()`` with +``ENOEXEC``, and with binfmt debug output enabled the loader reports:: + + ERROR: Module does not declare __nxflat_abi_v2: it was built by a + toolchain predating the r9 PIC base register. Rebuild it. + +Rebuilding the module with the current ``mknxflat`` is the entire fix; +nothing in the module source has to change. A module built against a newer +ABI than the firmware fails the other way, with ``Exported symbol +"__nxflat_abi_vN" not found`` and ``ENOENT``. + +The marker resolves like any other import, so the exported symbol table +passed to ``exec()`` has to contain it. A table generated from the modules' +thunk files, the way ``apps/tools/mksymtab.sh`` generates one, picks it up +automatically; a hand-written table has to list it. + Where the ARM PIC flags come from --------------------------------- @@ -338,25 +371,25 @@ On ARM the compilation flags described under **Target 1** are supplied by ``arch/arm/src/common/Toolchain.defs``, not by each board. A board only has to say something when it differs from the default:: - ARCHPICFLAGS ?= -fpic -msingle-pic-base -mpic-register=r10 + ARCHPICFLAGS ?= -fpic -msingle-pic-base -mpic-register=r9 - CPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r10,$(CFLAGS)) - CXXPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r10,$(CXXFLAGS)) + CPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r9,$(CFLAGS)) + CXXPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r9,$(CXXFLAGS)) ``ARCHPICFLAGS`` uses ``?=``, and the two derived variables use deferred ``=``, so a board that includes this file may still override ``ARCHPICFLAGS`` afterwards or append to it, and ``CFLAGS`` is whatever the -board finally set it to. A few boards do differ: one adds ``-ffixed-r10`` -and one conditionally adds ``-mno-pic-data-is-text-relative``. +board finally set it to. One board does differ: lm3s6965-ek conditionally +appends ``-mno-pic-data-is-text-relative``. -Reserving r10 in the base firmware ----------------------------------- +Reserving r9 in the base firmware +--------------------------------- -A module reaches its data through r10, and the base firmware has to leave +A module reaches its data through r9, and the base firmware has to leave that register alone -- otherwise a call *back* from the firmware into module code arrives with the wrong data base. ``qsort()`` with a comparison function inside the module is the usual way to meet this. Under -``CONFIG_PIC`` the firmware is therefore built with ``--fixed-r10``. +``CONFIG_PIC`` the firmware is therefore built with ``--fixed-r9``. That flag goes into ``ARCHCFLAGS`` rather than ``CFLAGS``, because nearly every board ``Make.defs`` includes ``Toolchain.defs`` and then assigns:: @@ -369,8 +402,8 @@ remote from the cause: everything builds, and only a callback into module code misbehaves. The two sides of that contract cannot both appear on one command line. A -module gets r10 through ``-mpic-register=r10``, and GCC rejects it alongside -``--fixed-r10`` with *"unable to use 'r10' for PIC register"*. Since +module gets r9 through ``-mpic-register=r9``, and GCC rejects it alongside +``--fixed-r9`` with *"unable to use 'r9' for PIC register"*. Since ``CPICFLAGS``, ``CXXPICFLAGS``, ``CELFFLAGS`` and ``CXXELFFLAGS`` all derive from ``CFLAGS``, the flag is filtered back out where they are defined, rather than in every board that builds modules. @@ -387,7 +420,7 @@ without PIC: .. code-block:: asm ldr r1, .L0 /* Fetch the offset to 'x' */ - ldr r0, [r10, r1] /* Load the value of 'x' with PIC offset */ + ldr r0, [r9, r1] /* Load the value of 'x' with PIC offset */ /* ... */ .L0: .word x /* Offset to 'x' */ @@ -397,7 +430,7 @@ generate code like this: .. code-block:: asm ldr r1, .L0 /* Fetch the offset to the GOT entry */ - ldr r1, [r10, r1] /* Fetch the (relocated) address of 'x' from the GOT */ + ldr r1, [r9, r1] /* Fetch the (relocated) address of 'x' from the GOT */ ldr r0, [r1, #0] /* Fetch the value of 'x' */ /* ... */ .L1 .word x(GOT) /* Offset to entry in the GOT */ @@ -429,7 +462,7 @@ contiguous (virtual) address space like:: .data .bss -It assumes that the PIC base register (usually r10 for ARM) points to +It assumes that the PIC base register (r9 for ARM) points to the base of ``.text`` so that any address in ``.text``, ``.got``, ``.data``, ``.bss`` can be found with an offset from the same base address. But that is not the memory arrangement that we need in the XIP diff --git a/Documentation/guides/porting-case-studies/port_arm_cm4.rst b/Documentation/guides/porting-case-studies/port_arm_cm4.rst index 410b21b7b3b23..742d15b5ec264 100644 --- a/Documentation/guides/porting-case-studies/port_arm_cm4.rst +++ b/Documentation/guides/porting-case-studies/port_arm_cm4.rst @@ -641,7 +641,7 @@ Appendix : out-of-tree code + +ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) + - +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r9 + +CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/Documentation/platforms/arm/rp23xx/boards/pimoroni-pico-2-plus/index.rst b/Documentation/platforms/arm/rp23xx/boards/pimoroni-pico-2-plus/index.rst index 4dc1f70f3bcef..8269cc7788c05 100644 --- a/Documentation/platforms/arm/rp23xx/boards/pimoroni-pico-2-plus/index.rst +++ b/Documentation/platforms/arm/rp23xx/boards/pimoroni-pico-2-plus/index.rst @@ -181,5 +181,5 @@ xipfs-nxflat ------------ Same as ``xipfs``, plus the NXFLAT execute-in-place demo. Building this -configuration requires the NXFLAT tools (``mknxflat`` and ``ldnxflat``), -which are not part of a standard toolchain installation. +configuration requires ``ldnxflat``, which is not part of a standard +toolchain installation; see :doc:`/components/nxflat`. diff --git a/arch/arm/include/arch.h b/arch/arm/include/arch.h index 3450f5c50df39..786f7e6cbd2ca 100644 --- a/arch/arm/include/arch.h +++ b/arch/arm/include/arch.h @@ -43,12 +43,14 @@ #ifdef CONFIG_PIC -/* This identifies the register the is used by the processor as the PIC base - * register. It is usually r9 or r10 +/* This identifies the register that is used by the processor as the PIC base + * register. r9 is the AAPCS platform register (the "static base"), which is + * also what GCC picks for -msingle-pic-base on an EABI target, so the whole + * of PIC uses it: NXFLAT, ELF PIC, and CONFIG_BUILD_PIC alike. */ -#define PIC_REG r10 -#define PIC_REG_STRING "r10" +#define PIC_REG r9 +#define PIC_REG_STRING "r9" /* Macros to get and set the PIC base register. picbase is assumed to be * of type (void*) and that it will fit into a uint32_t. These must be diff --git a/arch/arm/include/arm/irq.h b/arch/arm/include/arm/irq.h index 61b68a1cae2b4..ae79890a483b6 100644 --- a/arch/arm/include/arm/irq.h +++ b/arch/arm/include/arm/irq.h @@ -96,11 +96,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /**************************************************************************** * Public Types diff --git a/arch/arm/include/armv6-m/irq.h b/arch/arm/include/armv6-m/irq.h index 7a83579d1b572..0ba5a426c4718 100644 --- a/arch/arm/include/armv6-m/irq.h +++ b/arch/arm/include/armv6-m/irq.h @@ -123,11 +123,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /* CONTROL register */ diff --git a/arch/arm/include/armv7-a/irq.h b/arch/arm/include/armv7-a/irq.h index b9f973b627bce..bf1a5083dcb54 100644 --- a/arch/arm/include/armv7-a/irq.h +++ b/arch/arm/include/armv7-a/irq.h @@ -200,11 +200,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */ diff --git a/arch/arm/include/armv7-m/irq.h b/arch/arm/include/armv7-m/irq.h index 1f37bb6fbb546..cfb3d686dbeef 100644 --- a/arch/arm/include/armv7-m/irq.h +++ b/arch/arm/include/armv7-m/irq.h @@ -180,11 +180,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /* CONTROL register */ diff --git a/arch/arm/include/armv7-r/irq.h b/arch/arm/include/armv7-r/irq.h index 2e0706e1c928d..c038ce445d1b9 100644 --- a/arch/arm/include/armv7-r/irq.h +++ b/arch/arm/include/armv7-r/irq.h @@ -200,11 +200,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */ diff --git a/arch/arm/include/armv8-m/irq.h b/arch/arm/include/armv8-m/irq.h index 3d4290eeb7fb2..a7abf1c796284 100644 --- a/arch/arm/include/armv8-m/irq.h +++ b/arch/arm/include/armv8-m/irq.h @@ -186,11 +186,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /* CONTROL register */ diff --git a/arch/arm/include/armv8-r/irq.h b/arch/arm/include/armv8-r/irq.h index bc6f282360d65..45340dd94e140 100644 --- a/arch/arm/include/armv8-r/irq.h +++ b/arch/arm/include/armv8-r/irq.h @@ -200,11 +200,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /* Multiprocessor Affinity Register (MPIDR): CRn=c0, opc1=0, CRm=c0, opc2=5 */ diff --git a/arch/arm/include/tlsr82/irq.h b/arch/arm/include/tlsr82/irq.h index a8a551cbe3eb8..39aaffaaafb74 100644 --- a/arch/arm/include/tlsr82/irq.h +++ b/arch/arm/include/tlsr82/irq.h @@ -127,11 +127,11 @@ #define REG_LR REG_R14 #define REG_PC REG_R15 -/* The PIC register is usually R10. It can be R9 is stack checking is enabled - * or if the user changes it with -mpic-register on the GCC command line. +/* The PIC base register is R9, the AAPCS platform register. See PIC_REG + * in arch/arm/include/arch.h; every PIC binary format uses the same one. */ -#define REG_PIC REG_R10 +#define REG_PIC REG_R9 /**************************************************************************** * Public Types diff --git a/arch/arm/src/arm/arm_initialstate.c b/arch/arm/src/arm/arm_initialstate.c index f8deb39b7af15..fa1e990a60fa6 100644 --- a/arch/arm/src/arm/arm_initialstate.c +++ b/arch/arm/src/arm/arm_initialstate.c @@ -108,8 +108,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/armv6-m/arm_initialstate.c b/arch/arm/src/armv6-m/arm_initialstate.c index 4953e93860b02..2040d61690237 100644 --- a/arch/arm/src/armv6-m/arm_initialstate.c +++ b/arch/arm/src/armv6-m/arm_initialstate.c @@ -119,8 +119,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/armv7-a/arm_initialstate.c b/arch/arm/src/armv7-a/arm_initialstate.c index d66ff59150e51..c0f9dd469e480 100644 --- a/arch/arm/src/armv7-a/arm_initialstate.c +++ b/arch/arm/src/armv7-a/arm_initialstate.c @@ -115,8 +115,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/armv7-m/arm_initialstate.c b/arch/arm/src/armv7-m/arm_initialstate.c index 0cab69f30d883..43b96b615ee78 100644 --- a/arch/arm/src/armv7-m/arm_initialstate.c +++ b/arch/arm/src/armv7-m/arm_initialstate.c @@ -126,8 +126,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/armv7-r/arm_initialstate.c b/arch/arm/src/armv7-r/arm_initialstate.c index b1b6a8ac3825a..17b01c2327b99 100644 --- a/arch/arm/src/armv7-r/arm_initialstate.c +++ b/arch/arm/src/armv7-r/arm_initialstate.c @@ -108,8 +108,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/armv8-m/arm_initialstate.c b/arch/arm/src/armv8-m/arm_initialstate.c index 962050fa2c0af..fc316998ed79f 100644 --- a/arch/arm/src/armv8-m/arm_initialstate.c +++ b/arch/arm/src/armv8-m/arm_initialstate.c @@ -137,8 +137,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/armv8-r/arm_initialstate.c b/arch/arm/src/armv8-r/arm_initialstate.c index a8d91713d9932..89d39d501e9db 100644 --- a/arch/arm/src/armv8-r/arm_initialstate.c +++ b/arch/arm/src/armv8-r/arm_initialstate.c @@ -108,8 +108,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/arch/arm/src/cmake/elf.cmake b/arch/arm/src/cmake/elf.cmake index bd5a4bedef001..7108aa4c17485 100644 --- a/arch/arm/src/cmake/elf.cmake +++ b/arch/arm/src/cmake/elf.cmake @@ -27,7 +27,12 @@ nuttx_mod_compile_options(-fvisibility=hidden -mlong-calls) nuttx_elf_compile_options_ifdef(CONFIG_UNWINDER_ARM -fno-unwind-tables -fno-asynchronous-unwind-tables) -nuttx_elf_compile_options_ifdef(CONFIG_PIC --fixed-r10 -mpic-register=r10) +# An ELF module needs r9 as its PIC base, so it must not also have the register +# fixed: GCC rejects that pair with "unable to use 'r9' for PIC register". This +# mirrors CELFFLAGS in common/Toolchain.defs, which filters --fixed-r9 back out +# of the inherited CFLAGS for the same reason. + +nuttx_elf_compile_options_ifdef(CONFIG_PIC -mpic-register=r9) nuttx_elf_link_options_ifdef( CONFIG_PIC --unresolved-symbols=ignore-in-object-files --emit-relocs) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index c535bde05aa5d..734762fbb30fc 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -569,26 +569,47 @@ PICFLAGS = -fpic -fPIE -mno-pic-data-is-text-relative -msingle-pic-base # Flags for building PIC modules (NXFLAT). These were repeated verbatim in # every ARM board Make.defs; they live here so a board only has to say -# something when it differs, and so the interaction with --fixed-r10 below +# something when it differs, and so the interaction with --fixed-r9 below # can be handled in one place instead of 260. # # A board that needs to differ can still assign ARCHPICFLAGS after including # this file, which overrides the default, or append to it. -ARCHPICFLAGS ?= -fpic -msingle-pic-base -mpic-register=r10 +ARCHPICFLAGS ?= -fpic -msingle-pic-base -mpic-register=r9 -# --fixed-r10 reserves r10 across the base firmware so a callback into -# module code arrives with the module's data base intact. A module is the -# other side of that contract: it gets r10 via -mpic-register=r10, and GCC -# rejects a command line carrying both with "unable to use 'r10' for PIC -# register". Since these derive from CFLAGS, the flag has to come back out -# here. +# mknxflat generates a module's import thunks, and the instruction set it +# emits them in has to match the module. Supplied centrally for the same +# reason as ARCHPICFLAGS above: every board that builds NXFLAT modules was +# naming the same tool, and only the ARM/Thumb-2 choice actually varies. +# Boards using the ARM instruction set -- dm320, lpc31xx and moxart -- fall +# out of CONFIG_ARM_THUMB rather than having to say anything. + +ifeq ($(CONFIG_NXFLAT),y) + ifeq ($(CONFIG_ARM_THUMB),y) + MKNXFLAT ?= $(TOPDIR)$(DELIM)tools$(DELIM)mknxflat$(HOSTEXEEXT) -a thumb2 + else + MKNXFLAT ?= $(TOPDIR)$(DELIM)tools$(DELIM)mknxflat$(HOSTEXEEXT) -a arm + endif + + # ldnxflat is still an out-of-tree tool, so this is a PATH lookup. It is + # named here only so that a board which never assigned it -- lm3s6965-ek + # is one -- does not expand it to nothing and hand make a recipe starting + # with '-e', whose leading dash make then eats as "ignore errors". + + LDNXFLAT ?= ldnxflat +endif + +# --fixed-r9 reserves r9 across the base firmware so a callback into module +# code arrives with the module's data base intact. A module is the other +# side of that contract: it gets r9 via -mpic-register=r9, and GCC rejects a +# command line carrying both with "unable to use 'r9' for PIC register". +# Since these derive from CFLAGS, the flag has to come back out here. # # Both are deferred assignments, so CFLAGS and CXXFLAGS are whatever the # board finally set them to, even though this file is included first. -CPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r10,$(CFLAGS)) -CXXPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r10,$(CXXFLAGS)) +CPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r9,$(CFLAGS)) +CXXPICFLAGS = $(ARCHPICFLAGS) $(filter-out --fixed-r9,$(CXXFLAGS)) ifneq ($(CONFIG_BUILD_PIC),) ARCHCFLAGS += $(PICFLAGS) -mpic-register=r9 @@ -603,22 +624,22 @@ LDMODULEFLAGS = -r -T $(call CONVERT_PATH,$(TOPDIR)/libs/libc/elf/gnu-elf.ld) # ELF module definitions -# --fixed-r10 is filtered out for the same reason as in CPICFLAGS above: -# under CONFIG_PIC these gain -mpic-register=r10, which GCC will not +# --fixed-r9 is filtered out for the same reason as in CPICFLAGS above: +# under CONFIG_PIC these gain -mpic-register=r9, which GCC will not # accept alongside it. -CELFFLAGS = $(filter-out --fixed-r10,$(CFLAGS)) -fvisibility=hidden \ +CELFFLAGS = $(filter-out --fixed-r9,$(CFLAGS)) -fvisibility=hidden \ -mlong-calls # --target1-abs -CXXELFFLAGS = $(filter-out --fixed-r10,$(CXXFLAGS)) -fvisibility=hidden \ +CXXELFFLAGS = $(filter-out --fixed-r9,$(CXXFLAGS)) -fvisibility=hidden \ -mlong-calls ifeq ($(CONFIG_PIC),y) # ARCHCFLAGS, not CFLAGS: board Make.defs reassign CFLAGS with ':=' # after including this file, which would discard the flag. - ARCHCFLAGS += --fixed-r10 - CELFFLAGS += $(PICFLAGS) -mpic-register=r10 - CXXELFFLAGS += $(PICFLAGS) -mpic-register=r10 + ARCHCFLAGS += --fixed-r9 + CELFFLAGS += $(PICFLAGS) -mpic-register=r9 + CXXELFFLAGS += $(PICFLAGS) -mpic-register=r9 # Generate an executable elf, need to ignore undefined symbols LDELFFLAGS += --unresolved-symbols=ignore-in-object-files --emit-relocs diff --git a/arch/arm/src/tlsr82/tc32/tc32_initialstate.c b/arch/arm/src/tlsr82/tc32/tc32_initialstate.c index 78d05c4f072b3..05f388215ea83 100644 --- a/arch/arm/src/tlsr82/tc32/tc32_initialstate.c +++ b/arch/arm/src/tlsr82/tc32/tc32_initialstate.c @@ -111,8 +111,8 @@ void up_initial_state(struct tcb_s *tcb) #ifdef CONFIG_PIC if (tcb->dspace != NULL) { - /* Set the PIC base register (probably R10) to the address of the - * alloacated D-Space region. + /* Set the PIC base register (R9) to the address of the allocated + * D-Space region. */ xcp->regs[REG_PIC] = (uint32_t)tcb->dspace->region; diff --git a/binfmt/libnxflat/libnxflat_bind.c b/binfmt/libnxflat/libnxflat_bind.c index d6cda5c437006..73a75f55b21a5 100644 --- a/binfmt/libnxflat/libnxflat_bind.c +++ b/binfmt/libnxflat/libnxflat_bind.c @@ -29,6 +29,7 @@ #include #include +#include #include #include #include @@ -60,6 +61,22 @@ # define nxflat_dumpbuffer(m,b,n) #endif +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* The module ABI marker. Every module built by tools/nxflat/mknxflat + * imports this, and a board's exported symbol table picks it up the same + * way it picks up any other imported name, so nothing has to special-case + * it in the build. Its value is never used; only its presence matters. + * + * A module built against a newer ABI than the firmware therefore fails + * with "Exported symbol __nxflat_abi_vN not found", which names the + * problem, and a module built against an older one is caught below. + */ + +void *NXFLAT_ABI_MARKER; + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -384,6 +401,7 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo, FAR char *symname; uint32_t offset; uint16_t nimports; + bool abi_ok = false; #ifdef CONFIG_ARCH_ADDRENV int ret; #endif @@ -461,6 +479,17 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo, symname = (FAR char *) (offset + loadinfo->ispace + sizeof(struct nxflat_hdr_s)); + /* Note the ABI marker as it goes past. It resolves like any + * other import -- the base firmware defines it below -- so the + * only thing special about it is that its absence means the + * module was built before the ABI it names. + */ + + if (strcmp(symname, NXFLAT_ABI_SYMBOL) == 0) + { + abi_ok = true; + } + /* Find the exported symbol value for this symbol name. */ symbol = symtab_findbyname(exports, symname, nexports); @@ -484,6 +513,24 @@ static inline int nxflat_bindimports(FAR struct nxflat_loadinfo_s *loadinfo, /* Dump the relocation import table */ + /* A module that never declared the ABI was built by a toolchain older + * than the move of the PIC base register to r9. Its import thunks add + * r10, so it would load here and then branch to a wild address on its + * first call into the base firmware. Refuse it while there is still + * something useful to say about it. + */ + + if (!abi_ok) + { + berr("ERROR: Module does not declare " NXFLAT_ABI_SYMBOL ": it was " + "built by a toolchain predating the r9 PIC base register. " + "Rebuild it.\n"); +#ifdef CONFIG_ARCH_ADDRENV + nxflat_addrenv_restore(loadinfo); +#endif + return -ENOEXEC; + } + #ifdef CONFIG_NXFLAT_DUMPBUFFER if (nimports > 0) { diff --git a/boards/arm/am67/t3-gem-o1/scripts/Make.defs b/boards/arm/am67/t3-gem-o1/scripts/Make.defs index a17824ff40186..dd3d7507c9500 100644 --- a/boards/arm/am67/t3-gem-o1/scripts/Make.defs +++ b/boards/arm/am67/t3-gem-o1/scripts/Make.defs @@ -27,7 +27,6 @@ include $(TOPDIR)/arch/arm/src/armv7-r/Toolchain.defs LDSCRIPT = sdram.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 -ffixed-r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/cxd56xx/spresense/scripts/Make.defs b/boards/arm/cxd56xx/spresense/scripts/Make.defs index 936ca6d4881a6..c0f46863b656a 100644 --- a/boards/arm/cxd56xx/spresense/scripts/Make.defs +++ b/boards/arm/cxd56xx/spresense/scripts/Make.defs @@ -35,8 +35,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat ARCHCFLAGS += -mabi=aapcs diff --git a/boards/arm/dm320/ntosd-dm320/scripts/Make.defs b/boards/arm/dm320/ntosd-dm320/scripts/Make.defs index 1e5c6aea09ad8..61237c3ea64fc 100644 --- a/boards/arm/dm320/ntosd-dm320/scripts/Make.defs +++ b/boards/arm/dm320/ntosd-dm320/scripts/Make.defs @@ -26,8 +26,6 @@ include $(TOPDIR)/arch/arm/src/arm/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)sdram.ld -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} diff --git a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs index 63f4c62090400..4f43409b4ebed 100644 --- a/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1050-evk/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs index 471d9edf96404..948fe457d93de 100644 --- a/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1060-evk/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs index 7e0a473846363..41d406fe7bdc3 100644 --- a/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1064-evk/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/imxrt/imxrt1170-evk/configs/knsh/Make.defs b/boards/arm/imxrt/imxrt1170-evk/configs/knsh/Make.defs index b07e57507b327..0aa64e7025726 100644 --- a/boards/arm/imxrt/imxrt1170-evk/configs/knsh/Make.defs +++ b/boards/arm/imxrt/imxrt1170-evk/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe diff --git a/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs index 9da03dbc649e9..c8cb6fb68fafa 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpc4088-devkit/configs/knsh/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs index 2e977c107419c..86b4e6f66328c 100644 --- a/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpc4088-quickstart/configs/knsh/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs index ae1e3d3644675..1716e72c516ca 100644 --- a/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs +++ b/boards/arm/lpc17xx_40xx/lpcxpresso-lpc1768/configs/thttpd/Make.defs @@ -25,10 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs NXFLATLDSCRIPT = -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-gotoff.ld) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat - -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs index 278a392cb0836..d4bdbc4312f76 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-binfs/Make.defs @@ -24,10 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat - -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs index d8b04e9ed40f0..e41cbcf38d8fa 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/configs/thttpd-nxflat/Make.defs @@ -24,10 +24,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat - -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs index 01fce49559891..56783e1858ab5 100644 --- a/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/olimex-lpc1766stk/scripts/Make.defs @@ -26,8 +26,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs index 3bea3a0ad5b8f..589ce3019b256 100644 --- a/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/open1788/configs/knsh/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs b/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs index 17437d4efd18c..7b5eed58d3bb8 100644 --- a/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs +++ b/boards/arm/lpc17xx_40xx/open1788/configs/knxterm/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs b/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs index 408da24d82a29..bed1fad071427 100644 --- a/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs +++ b/boards/arm/lpc17xx_40xx/pnev5180b/configs/knsh/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs b/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs index 6787bb34f0861..1699a8934d7ba 100644 --- a/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs +++ b/boards/arm/lpc17xx_40xx/zkit-arm-1769/scripts/Make.defs @@ -27,8 +27,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs NXFLATLDSCRIPT = -T $(call CONVERT_PATH,$(TOPDIR)$(DELIM)binfmt$(DELIM)libnxflat$(DELIM)gnu-nxflat-gotoff.ld) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)ld.script -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs b/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs index 6be0fbb810a1c..838c1e486b68f 100644 --- a/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs +++ b/boards/arm/lpc31xx/ea3131/configs/pgnsh/Make.defs @@ -41,8 +41,6 @@ else ARCHCPUFLAGS = -mapcs-32 -mtune=arm9tdmi -march=armv5te -msoft-float endif -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/moxart/moxa/scripts/Make.defs b/boards/arm/moxart/moxa/scripts/Make.defs index 503b4d4a1ba4b..bcb7793acb7b2 100644 --- a/boards/arm/moxart/moxa/scripts/Make.defs +++ b/boards/arm/moxart/moxa/scripts/Make.defs @@ -34,8 +34,6 @@ CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections diff --git a/boards/arm/rp23xx/pimoroni-pico-2-plus/scripts/Make.defs b/boards/arm/rp23xx/pimoroni-pico-2-plus/scripts/Make.defs index fa4bfae9c517b..51fa9c5bca2bf 100644 --- a/boards/arm/rp23xx/pimoroni-pico-2-plus/scripts/Make.defs +++ b/boards/arm/rp23xx/pimoroni-pico-2-plus/scripts/Make.defs @@ -38,8 +38,6 @@ CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections diff --git a/boards/arm/rp23xx/raspberrypi-pico-2/scripts/Make.defs b/boards/arm/rp23xx/raspberrypi-pico-2/scripts/Make.defs index c50a89026bca2..cd582cf60437d 100644 --- a/boards/arm/rp23xx/raspberrypi-pico-2/scripts/Make.defs +++ b/boards/arm/rp23xx/raspberrypi-pico-2/scripts/Make.defs @@ -38,8 +38,6 @@ CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections diff --git a/boards/arm/rp23xx/xiao-rp2350/scripts/Make.defs b/boards/arm/rp23xx/xiao-rp2350/scripts/Make.defs index ccf52abfac7ac..b649916383ce0 100644 --- a/boards/arm/rp23xx/xiao-rp2350/scripts/Make.defs +++ b/boards/arm/rp23xx/xiao-rp2350/scripts/Make.defs @@ -38,8 +38,6 @@ CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections diff --git a/boards/arm/s32k3xx/mr-canhubk3/configs/knsh/Make.defs b/boards/arm/s32k3xx/mr-canhubk3/configs/knsh/Make.defs index 50e56ffedfc5a..4a36ec50fa1e9 100644 --- a/boards/arm/s32k3xx/mr-canhubk3/configs/knsh/Make.defs +++ b/boards/arm/s32k3xx/mr-canhubk3/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs b/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs index 3e6db6ea30850..5cbc0bac7fbb7 100644 --- a/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs +++ b/boards/arm/sam34/sam3u-ek/configs/knsh/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/sama5/sama5d3-xplained/configs/knsh/Make.defs b/boards/arm/sama5/sama5d3-xplained/configs/knsh/Make.defs index 7a229551c78bb..12bb8e1ae72b9 100644 --- a/boards/arm/sama5/sama5d3-xplained/configs/knsh/Make.defs +++ b/boards/arm/sama5/sama5d3-xplained/configs/knsh/Make.defs @@ -32,8 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs b/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs index 2d2ad887bdf0c..c325725fccac3 100644 --- a/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs +++ b/boards/arm/sama5/sama5d4-ek/configs/knsh/Make.defs @@ -36,8 +36,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs index 7eac71be7abc1..bb85c2ca96a7a 100644 --- a/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs +++ b/boards/arm/samv7/samv71-xult/configs/knsh/Make.defs @@ -41,8 +41,6 @@ else ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld endif -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f1/shenzhou/scripts/Make.defs b/boards/arm/stm32f1/shenzhou/scripts/Make.defs index f0f931facc6ca..54e7e4962dc76 100644 --- a/boards/arm/stm32f1/shenzhou/scripts/Make.defs +++ b/boards/arm/stm32f1/shenzhou/scripts/Make.defs @@ -34,8 +34,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f4/olimex-stm32-p407/configs/kelf/Make.defs b/boards/arm/stm32f4/olimex-stm32-p407/configs/kelf/Make.defs index 9c06da91d4e6e..013f773a34919 100644 --- a/boards/arm/stm32f4/olimex-stm32-p407/configs/kelf/Make.defs +++ b/boards/arm/stm32f4/olimex-stm32-p407/configs/kelf/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f4/olimex-stm32-p407/configs/kmodule/Make.defs b/boards/arm/stm32f4/olimex-stm32-p407/configs/kmodule/Make.defs index 22979d8184d48..eed982769a167 100644 --- a/boards/arm/stm32f4/olimex-stm32-p407/configs/kmodule/Make.defs +++ b/boards/arm/stm32f4/olimex-stm32-p407/configs/kmodule/Make.defs @@ -25,8 +25,6 @@ include $(TOPDIR)/arch/arm/src/armv7-m/Toolchain.defs ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f4/olimex-stm32-p407/configs/knsh/Make.defs b/boards/arm/stm32f4/olimex-stm32-p407/configs/knsh/Make.defs index f9a6444eca014..9b841d6f4075e 100644 --- a/boards/arm/stm32f4/olimex-stm32-p407/configs/knsh/Make.defs +++ b/boards/arm/stm32f4/olimex-stm32-p407/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f4/stm3240g-eval/configs/knxwm/Make.defs b/boards/arm/stm32f4/stm3240g-eval/configs/knxwm/Make.defs index bdadecf86030b..1140d8f4fac5c 100644 --- a/boards/arm/stm32f4/stm3240g-eval/configs/knxwm/Make.defs +++ b/boards/arm/stm32f4/stm3240g-eval/configs/knxwm/Make.defs @@ -26,8 +26,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)memory.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)kernel-space.ld ARCHCXXFLAGS += -fpermissive -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f4/stm32f4discovery/configs/kostest/Make.defs b/boards/arm/stm32f4/stm32f4discovery/configs/kostest/Make.defs index 8c981466a321e..c89ccdb327f7a 100644 --- a/boards/arm/stm32f4/stm32f4discovery/configs/kostest/Make.defs +++ b/boards/arm/stm32f4/stm32f4discovery/configs/kostest/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32f4/stm32f4discovery/src/CMakeLists.txt b/boards/arm/stm32f4/stm32f4discovery/src/CMakeLists.txt index 36cebfbb8cf77..853db133b1ae5 100644 --- a/boards/arm/stm32f4/stm32f4discovery/src/CMakeLists.txt +++ b/boards/arm/stm32f4/stm32f4discovery/src/CMakeLists.txt @@ -182,7 +182,7 @@ set_property( # TODO: see where to put pic flags set_property(TARGET nuttx APPEND PROPERTY # NUTTX_COMPILE_OPTIONS $<$>:-fpic -msingle-pic-base -# -mpic-register=r10>) +# -mpic-register=r9>) # ifeq ($(CONFIG_ARMV7M_TOOLCHAIN_CLANGL),y) ARCHCFLAGS += -nostdlib # -ffreestanding ARCHCXXFLAGS += -nostdlib -ffreestanding else ARCHCFLAGS += diff --git a/boards/arm/stm32h7/devebox-stm32h743/scripts/Make.defs b/boards/arm/stm32h7/devebox-stm32h743/scripts/Make.defs index 69ef0f9202396..e91c28ac69d1a 100644 --- a/boards/arm/stm32h7/devebox-stm32h743/scripts/Make.defs +++ b/boards/arm/stm32h7/devebox-stm32h743/scripts/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT = flash.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe diff --git a/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs b/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs index 791ca4bdc6bf3..20c5b98f9a7ca 100644 --- a/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs +++ b/boards/arm/stm32l4/stm32l476vg-disco/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs b/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs index 6fac6302fa702..ed0a21f4292c0 100644 --- a/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs +++ b/boards/arm/stm32l4/stm32l4r9ai-disco/configs/knsh/Make.defs @@ -28,8 +28,6 @@ LDSCRIPT2 = kernel-space.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT1) ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT2) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 - CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/arm/tiva/eagle100/scripts/Make.defs b/boards/arm/tiva/eagle100/scripts/Make.defs index 125af333f8dd5..358a3d25e414a 100644 --- a/boards/arm/tiva/eagle100/scripts/Make.defs +++ b/boards/arm/tiva/eagle100/scripts/Make.defs @@ -31,8 +31,6 @@ CXXFLAGS := $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES CPPFLAGS := $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) AFLAGS := $(CFLAGS) -D__ASSEMBLY__ -MKNXFLAT = mknxflat -LDNXFLAT = ldnxflat NXFLATLDFLAGS1 = -r -d -warn-common NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections diff --git a/boards/avr/at32uc3/avr32dev1/scripts/Make.defs b/boards/avr/at32uc3/avr32dev1/scripts/Make.defs index 07f92e5ea93a1..64e31ad1f615b 100644 --- a/boards/avr/at32uc3/avr32dev1/scripts/Make.defs +++ b/boards/avr/at32uc3/avr32dev1/scripts/Make.defs @@ -28,7 +28,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)avr32dev1.ld ARCHCFLAGS = -muse-rodata-section ARCHNOPICFLAGS = -fno-pic -ARCHPICFLAGS = -fpic ARCHALLCFLAGS = $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) ARCHALLCXXFLAGS = $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/avr/at32uc3/mizar32a/scripts/Make.defs b/boards/avr/at32uc3/mizar32a/scripts/Make.defs index 137bf8fb92646..f374c3d22c817 100644 --- a/boards/avr/at32uc3/mizar32a/scripts/Make.defs +++ b/boards/avr/at32uc3/mizar32a/scripts/Make.defs @@ -28,7 +28,6 @@ ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)mizar32a.ld ARCHCFLAGS = -muse-rodata-section ARCHNOPICFLAGS = -fno-pic -ARCHPICFLAGS = -fpic ARCHALLCFLAGS = $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe ARCHALLCXXFLAGS = $(ARCHCXXFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe diff --git a/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs b/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs index 63e9f2ff0d2c5..55d43c86ff407 100644 --- a/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs +++ b/boards/hc/m9s12/demo9s12ne64/scripts/Make.defs @@ -54,7 +54,6 @@ ARCHCFLAGS = -fno-common ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/hc/m9s12/ne64badge/scripts/Make.defs b/boards/hc/m9s12/ne64badge/scripts/Make.defs index 1b9beb634e9f2..faef7bc49c6d8 100644 --- a/boards/hc/m9s12/ne64badge/scripts/Make.defs +++ b/boards/hc/m9s12/ne64badge/scripts/Make.defs @@ -54,7 +54,6 @@ ARCHCFLAGS = -fno-common ARCHCXXFLAGS = -fno-common -fno-exceptions -fcheck-new ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHWARNINGSXX = -Wall -Wshadow -Wundef -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/or1k/mor1kx/or1k/scripts/Make.defs b/boards/or1k/mor1kx/or1k/scripts/Make.defs index 6241cc1cb9cfa..a7437ba82d175 100644 --- a/boards/or1k/mor1kx/or1k/scripts/Make.defs +++ b/boards/or1k/mor1kx/or1k/scripts/Make.defs @@ -27,7 +27,6 @@ include $(TOPDIR)/arch/or1k/src/mor1kx/Toolchain.defs LDSCRIPT = flash.ld ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/renesas/m16c/skp16c26/scripts/Make.defs b/boards/renesas/m16c/skp16c26/scripts/Make.defs index 941ab9815d434..8a8228d4e4a15 100644 --- a/boards/renesas/m16c/skp16c26/scripts/Make.defs +++ b/boards/renesas/m16c/skp16c26/scripts/Make.defs @@ -41,7 +41,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) endif ARCHCPUFLAGS = -mcpu=m16c -ARCHPICFLAGS = -fpic ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)skp16c26.ld diff --git a/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs b/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs index 7df89e540b417..bf0f578c3fb62 100644 --- a/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n-grrose/scripts/Make.defs @@ -46,7 +46,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer endif -ARCHPICFLAGS = -fpic ARCHCFLAGS = -fno-common -std=c99 ARCHCPUFLAGS = -mcpu=rx64m ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef diff --git a/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs b/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs index df2bd460b502b..e00a3c9abefb7 100644 --- a/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n-rsk1mb/scripts/Make.defs @@ -46,7 +46,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer endif -ARCHPICFLAGS = -fpic ARCHCFLAGS = -fno-common -std=c99 ARCHCPUFLAGS = -mcpu=rx64m ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef diff --git a/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs b/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs index 92fe898cb51ec..2ca198d3784f7 100644 --- a/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n-rsk2mb/scripts/Make.defs @@ -46,7 +46,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer endif -ARCHPICFLAGS = -fpic ARCHCFLAGS = -fno-common -std=c99 ARCHCPUFLAGS = -mcpu=rx64m ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef diff --git a/boards/renesas/rx65n/rx65n/scripts/Make.defs b/boards/renesas/rx65n/rx65n/scripts/Make.defs index 09db0113da6ff..580b3f0301a18 100644 --- a/boards/renesas/rx65n/rx65n/scripts/Make.defs +++ b/boards/renesas/rx65n/rx65n/scripts/Make.defs @@ -46,7 +46,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -Os -fno-strict-aliasing -fomit-frame-pointer endif -ARCHPICFLAGS = -fpic ARCHCFLAGS = -fno-common -std=c99 ARCHCPUFLAGS = -mcpu=rx64m ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef diff --git a/boards/renesas/sh1/us7032evb1/scripts/Make.defs b/boards/renesas/sh1/us7032evb1/scripts/Make.defs index 533181b7c8b9e..ec2629c37ae98 100644 --- a/boards/renesas/sh1/us7032evb1/scripts/Make.defs +++ b/boards/renesas/sh1/us7032evb1/scripts/Make.defs @@ -32,7 +32,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) endif ARCHCPUFLAGS = -m1 -ARCHPICFLAGS = -fpic ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)sdram.ld diff --git a/boards/risc-v/bl602/bl602evb/scripts/Make.defs b/boards/risc-v/bl602/bl602evb/scripts/Make.defs index f431ac7cafaa2..c2d8ac83e8b51 100644 --- a/boards/risc-v/bl602/bl602evb/scripts/Make.defs +++ b/boards/risc-v/bl602/bl602evb/scripts/Make.defs @@ -31,7 +31,6 @@ LDSCRIPT = ld.script ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) ARCHCPUFLAGS += -mno-relax -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 ifeq ($(CONFIG_STACK_OVERFLOW_CHECK),y) ARCHCFLAGS += -finstrument-functions -ffixed-s11 diff --git a/boards/risc-v/bl808/ox64/scripts/Make.defs b/boards/risc-v/bl808/ox64/scripts/Make.defs index 3f58d8d898f7e..cfe3a2302b55b 100644 --- a/boards/risc-v/bl808/ox64/scripts/Make.defs +++ b/boards/risc-v/bl808/ox64/scripts/Make.defs @@ -26,7 +26,6 @@ include $(TOPDIR)/arch/risc-v/src/common/Toolchain.defs LDSCRIPT = ld.script ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) diff --git a/boards/risc-v/eic7700x/starpro64/scripts/Make.defs b/boards/risc-v/eic7700x/starpro64/scripts/Make.defs index 92115f10410cd..d885c4a4f99e4 100644 --- a/boards/risc-v/eic7700x/starpro64/scripts/Make.defs +++ b/boards/risc-v/eic7700x/starpro64/scripts/Make.defs @@ -26,7 +26,6 @@ include $(TOPDIR)/arch/risc-v/src/common/Toolchain.defs LDSCRIPT = ld.script ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit-rust-1/scripts/Make.defs b/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit-rust-1/scripts/Make.defs index 37192e755bc07..a11dc5d7c4afb 100644 --- a/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit-rust-1/scripts/Make.defs +++ b/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit-rust-1/scripts/Make.defs @@ -43,7 +43,6 @@ else endif endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit/scripts/Make.defs b/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit/scripts/Make.defs index 22722a9770451..8d5353f159406 100644 --- a/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit/scripts/Make.defs +++ b/boards/risc-v/esp32c3-legacy/esp32c3-legacy-devkit/scripts/Make.defs @@ -43,7 +43,6 @@ else endif endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c3/esp32-c3-zero/scripts/Make.defs b/boards/risc-v/esp32c3/esp32-c3-zero/scripts/Make.defs index d03f1ce93629a..2a8d0d887b2fa 100644 --- a/boards/risc-v/esp32c3/esp32-c3-zero/scripts/Make.defs +++ b/boards/risc-v/esp32c3/esp32-c3-zero/scripts/Make.defs @@ -43,7 +43,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs b/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs index 5bd6c9d784d14..85cbd4718a9e7 100644 --- a/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs +++ b/boards/risc-v/esp32c3/esp32c3-devkit/scripts/Make.defs @@ -43,7 +43,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c3/esp32c3-xiao/scripts/Make.defs b/boards/risc-v/esp32c3/esp32c3-xiao/scripts/Make.defs index 9f02ad2d5baf8..9796d14ed81cd 100644 --- a/boards/risc-v/esp32c3/esp32c3-xiao/scripts/Make.defs +++ b/boards/risc-v/esp32c3/esp32c3-xiao/scripts/Make.defs @@ -43,7 +43,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs b/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs index f27259234aaa1..d2af1cb4ca344 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs +++ b/boards/risc-v/esp32c6/esp32c6-devkitc/scripts/Make.defs @@ -43,7 +43,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c6/esp32c6-devkitm/scripts/Make.defs b/boards/risc-v/esp32c6/esp32c6-devkitm/scripts/Make.defs index 1fa5297fc017e..0885244f0cd3b 100644 --- a/boards/risc-v/esp32c6/esp32c6-devkitm/scripts/Make.defs +++ b/boards/risc-v/esp32c6/esp32c6-devkitm/scripts/Make.defs @@ -43,7 +43,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32c6/esp32c6-xiao/scripts/Make.defs b/boards/risc-v/esp32c6/esp32c6-xiao/scripts/Make.defs index a2bf50fe10020..55a42752727c8 100644 --- a/boards/risc-v/esp32c6/esp32c6-xiao/scripts/Make.defs +++ b/boards/risc-v/esp32c6/esp32c6-xiao/scripts/Make.defs @@ -43,7 +43,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32h2/esp32h2-devkit/scripts/Make.defs b/boards/risc-v/esp32h2/esp32h2-devkit/scripts/Make.defs index 61ff2c867b44d..e4010eaedf7e6 100644 --- a/boards/risc-v/esp32h2/esp32h2-devkit/scripts/Make.defs +++ b/boards/risc-v/esp32h2/esp32h2-devkit/scripts/Make.defs @@ -44,7 +44,6 @@ else ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_legacy_sections.ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32p4/esp32p4-function-ev-board/scripts/Make.defs b/boards/risc-v/esp32p4/esp32p4-function-ev-board/scripts/Make.defs index 573d5bbbf4cb7..89fb8a54273b3 100644 --- a/boards/risc-v/esp32p4/esp32p4-function-ev-board/scripts/Make.defs +++ b/boards/risc-v/esp32p4/esp32p4-function-ev-board/scripts/Make.defs @@ -46,7 +46,6 @@ else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_sections$(BOARD_REV).ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32p4/esp32p4-pico-wifi-wareshare/scripts/Make.defs b/boards/risc-v/esp32p4/esp32p4-pico-wifi-wareshare/scripts/Make.defs index 52bfaa33811e0..5d8639df55f09 100644 --- a/boards/risc-v/esp32p4/esp32p4-pico-wifi-wareshare/scripts/Make.defs +++ b/boards/risc-v/esp32p4/esp32p4-pico-wifi-wareshare/scripts/Make.defs @@ -46,7 +46,6 @@ else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_sections$(BOARD_REV).ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/esp32p4/esp32p4-tab5/scripts/Make.defs b/boards/risc-v/esp32p4/esp32p4-tab5/scripts/Make.defs index 2579d1ce72e1a..51e5bbbf46c55 100644 --- a/boards/risc-v/esp32p4/esp32p4-tab5/scripts/Make.defs +++ b/boards/risc-v/esp32p4/esp32p4-tab5/scripts/Make.defs @@ -46,7 +46,6 @@ else ifeq ($(CONFIG_ESPRESSIF_SIMPLE_BOOT),y) ARCHSCRIPT += $(call FINDSCRIPT,$(CHIP_SERIES)_sections$(BOARD_REV).ld) endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -Werror=return-type CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs b/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs index f8479460f0a46..30b318c26a101 100644 --- a/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs +++ b/boards/risc-v/fe310/hifive1-revb/scripts/Make.defs @@ -32,7 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/jh7110/star64/scripts/Make.defs b/boards/risc-v/jh7110/star64/scripts/Make.defs index faf5104864aa2..f4aebc2d14c5e 100644 --- a/boards/risc-v/jh7110/star64/scripts/Make.defs +++ b/boards/risc-v/jh7110/star64/scripts/Make.defs @@ -26,7 +26,6 @@ include $(TOPDIR)/arch/risc-v/src/common/Toolchain.defs LDSCRIPT = ld.script ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/k230/canmv230/scripts/Make.defs b/boards/risc-v/k230/canmv230/scripts/Make.defs index 13a6668085944..c4af2103c06fc 100644 --- a/boards/risc-v/k230/canmv230/scripts/Make.defs +++ b/boards/risc-v/k230/canmv230/scripts/Make.defs @@ -37,7 +37,6 @@ endif endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/litex/arty_a7/scripts/Make.defs b/boards/risc-v/litex/arty_a7/scripts/Make.defs index 207b83d03ef80..2ae942bcddcaa 100644 --- a/boards/risc-v/litex/arty_a7/scripts/Make.defs +++ b/boards/risc-v/litex/arty_a7/scripts/Make.defs @@ -32,7 +32,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs b/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs index 9b856a7a17b4a..b386933aaa822 100644 --- a/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs +++ b/boards/risc-v/qemu-rv/rv-virt/scripts/Make.defs @@ -37,7 +37,6 @@ endif endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/rp23xx-rv/raspberrypi-pico-2-rv/scripts/Make.defs b/boards/risc-v/rp23xx-rv/raspberrypi-pico-2-rv/scripts/Make.defs index db48603749912..ae3e7b01623d9 100644 --- a/boards/risc-v/rp23xx-rv/raspberrypi-pico-2-rv/scripts/Make.defs +++ b/boards/risc-v/rp23xx-rv/raspberrypi-pico-2-rv/scripts/Make.defs @@ -33,7 +33,6 @@ endif ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/risc-v/sg2000/milkv_duos/scripts/Make.defs b/boards/risc-v/sg2000/milkv_duos/scripts/Make.defs index cd93e12b27518..683f2d706b34a 100644 --- a/boards/risc-v/sg2000/milkv_duos/scripts/Make.defs +++ b/boards/risc-v/sg2000/milkv_duos/scripts/Make.defs @@ -26,7 +26,6 @@ include $(TOPDIR)/arch/risc-v/src/common/Toolchain.defs LDSCRIPT = ld.script ARCHSCRIPT += $(BOARD_DIR)$(DELIM)scripts$(DELIM)$(LDSCRIPT) -ARCHPICFLAGS = -fpic -msingle-pic-base CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/sim/sim/sim/scripts/Make.defs b/boards/sim/sim/sim/scripts/Make.defs index 0b61eaebddd9e..f3667253196e5 100644 --- a/boards/sim/sim/sim/scripts/Make.defs +++ b/boards/sim/sim/sim/scripts/Make.defs @@ -189,7 +189,6 @@ else ifeq ($(CONFIG_HOST_MACOS),y) LLVM_ABITYPE := sysv endif -ARCHPICFLAGS = -fpic CC = $(CROSSDEV)cc CXX = $(CROSSDEV)c++ diff --git a/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs b/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs index 708b3e9712322..3ee9a7c5f309e 100644 --- a/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-2432S028/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-audio-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-audio-kit/scripts/Make.defs index c29a96d044377..1f800c71de71b 100644 --- a/boards/xtensa/esp32/esp32-audio-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-audio-kit/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs b/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs index 93b0935821ca8..2dea0bfe291e4 100644 --- a/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-devkitc/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs index 7a318591d8fb6..9172fa600d1db 100644 --- a/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-ethernet-kit/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-lyrat/scripts/Make.defs b/boards/xtensa/esp32/esp32-lyrat/scripts/Make.defs index 332bd3d994de1..9c766b1fa45ff 100644 --- a/boards/xtensa/esp32/esp32-lyrat/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-lyrat/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-pico-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-pico-kit/scripts/Make.defs index 692e1e492e5a5..fbeb5730edf9a 100644 --- a/boards/xtensa/esp32/esp32-pico-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-pico-kit/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-sparrow-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-sparrow-kit/scripts/Make.defs index 27e393d35278a..422845482e18b 100644 --- a/boards/xtensa/esp32/esp32-sparrow-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-sparrow-kit/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs b/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs index 4e8ce30a04454..ba1de5aa51705 100644 --- a/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs +++ b/boards/xtensa/esp32/esp32-wrover-kit/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/heltec_wifi_lora32/scripts/Make.defs b/boards/xtensa/esp32/heltec_wifi_lora32/scripts/Make.defs index e4e3a18582898..c5245c12325ac 100644 --- a/boards/xtensa/esp32/heltec_wifi_lora32/scripts/Make.defs +++ b/boards/xtensa/esp32/heltec_wifi_lora32/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32/lilygo_tbeam_lora_gps/scripts/Make.defs b/boards/xtensa/esp32/lilygo_tbeam_lora_gps/scripts/Make.defs index 3ba9ebf273724..d7e2c93fa1fbd 100644 --- a/boards/xtensa/esp32/lilygo_tbeam_lora_gps/scripts/Make.defs +++ b/boards/xtensa/esp32/lilygo_tbeam_lora_gps/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/ttgo_eink5_v2/scripts/Make.defs b/boards/xtensa/esp32/ttgo_eink5_v2/scripts/Make.defs index 388cb0b078f4a..baaf36f61196b 100644 --- a/boards/xtensa/esp32/ttgo_eink5_v2/scripts/Make.defs +++ b/boards/xtensa/esp32/ttgo_eink5_v2/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs b/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs index 315d3333abb0b..4ba9bbec678b0 100644 --- a/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs +++ b/boards/xtensa/esp32/ttgo_lora_esp32/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32/ttgo_t_display_esp32/scripts/Make.defs b/boards/xtensa/esp32/ttgo_t_display_esp32/scripts/Make.defs index a6cb1db5cac26..e1f504fbb28bb 100644 --- a/boards/xtensa/esp32/ttgo_t_display_esp32/scripts/Make.defs +++ b/boards/xtensa/esp32/ttgo_t_display_esp32/scripts/Make.defs @@ -41,7 +41,6 @@ else endif endif -ARCHPICFLAGS = -fpic # if SPIRAM/PSRAM is used then we need to include a workaround diff --git a/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs b/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs index 3e03cc8b3dbcf..9969e935a3d20 100644 --- a/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs +++ b/boards/xtensa/esp32s2/esp32s2-kaluga-1/scripts/Make.defs @@ -34,7 +34,6 @@ ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_peripherals.ld ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld) ARCHSCRIPT += $(call FINDSCRIPT,esp32s2_sections.ld) -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs index c60872364c8ac..01b7bd9f139fa 100644 --- a/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs +++ b/boards/xtensa/esp32s2/esp32s2-saola-1/scripts/Make.defs @@ -34,7 +34,6 @@ ARCHSCRIPT += $(BOARD_COMMON_DIR)$(DELIM)scripts$(DELIM)esp32s2_peripherals.ld ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld) ARCHSCRIPT += $(call FINDSCRIPT,esp32s2_sections.ld) -ARCHPICFLAGS = -fpic ifeq ($(CONFIG_DEBUG_FULLOPT),y) ARCHOPTIMIZATION += -fno-omit-frame-pointer diff --git a/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs b/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs index e55715acc728f..e48003fe374a8 100644 --- a/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs +++ b/boards/xtensa/esp32s2/franzininho-wifi/scripts/Make.defs @@ -35,7 +35,6 @@ ARCHSCRIPT += $(call FINDSCRIPT,flat_memory.ld) ARCHSCRIPT += $(call FINDSCRIPT,esp32s2_sections.ld) -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-8048S043/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-8048S043/scripts/Make.defs index df22216cd22da..33998679b7eda 100644 --- a/boards/xtensa/esp32s3/esp32s3-8048S043/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-8048S043/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-box/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-box/scripts/Make.defs index f001355d0cc17..25b3cc4181c88 100644 --- a/boards/xtensa/esp32s3/esp32s3-box/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-box/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs index c0d223a3302f9..50ac3ee2b69a1 100644 --- a/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-devkit/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-eye/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-eye/scripts/Make.defs index 5b109216ab597..4eb7bdea2581c 100644 --- a/boards/xtensa/esp32s3/esp32s3-eye/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-eye/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs index 1cdde66808a6f..430701deaa92a 100644 --- a/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-korvo-2/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) -pipe CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs index 40bd65d059dd5..96ba2f7eba57c 100644 --- a/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-lcd-ev/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs index 696a25653c33b..37aa9f31b0e2f 100644 --- a/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-lhcbit/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-m5-cardputer/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-m5-cardputer/scripts/Make.defs index d22e312714360..701ed89afcbe4 100644 --- a/boards/xtensa/esp32s3/esp32s3-m5-cardputer/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-m5-cardputer/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-meadow/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-meadow/scripts/Make.defs index 6a4bc82715ca2..eef1ecaa23554 100644 --- a/boards/xtensa/esp32s3/esp32s3-meadow/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-meadow/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs index dc7d09f5ab736..2b2e7eec049f4 100644 --- a/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-ws-lcd128/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs b/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs index 62ab9a5805fbc..5e591d98e673e 100644 --- a/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs +++ b/boards/xtensa/esp32s3/esp32s3-xiao/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/scripts/Make.defs b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/scripts/Make.defs index ff7559bb6446c..d4a795a6f3396 100644 --- a/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/scripts/Make.defs +++ b/boards/xtensa/esp32s3/lckfb-szpi-esp32s3/scripts/Make.defs @@ -47,7 +47,6 @@ ifneq ($(CONFIG_DEBUG_NOOPT),y) ARCHOPTIMIZATION += -fno-strength-reduce endif -ARCHPICFLAGS = -fpic CFLAGS := $(ARCHCFLAGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRAFLAGS) CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) diff --git a/include/nxflat.h b/include/nxflat.h index 9b93c7bf8f241..b87314fe0fff0 100644 --- a/include/nxflat.h +++ b/include/nxflat.h @@ -39,6 +39,26 @@ #define NXFLAT_MAX_STRING_SIZE 64 /* Largest size of string (w/zterminator) */ #define NXFLAT_MAGIC "NxFT" /* NXFLAT magic number */ +/* Every module built by tools/nxflat/mknxflat imports this name, and the + * loader refuses a module that does not. + * + * The header cannot carry a version: h_magic is written by ldnxflat, which + * is GPL and stays out of this repository, so it can never be changed in + * step with the loader. The import table can, because both ends of it are + * in-tree -- mknxflat emits it and nxflat_bindimports() reads it -- and + * ldnxflat passes it through untouched. + * + * Bump the generation when the module ABI changes. v2 is the move of the + * PIC base register from r10 to r9; a v1 module's import thunks add the + * wrong register and would branch to a wild address on their first call + * into the base firmware. + * + * Must match NXFLAT_ABI_SYMBOL in tools/nxflat/nxflat_thunk.h. + */ + +#define NXFLAT_ABI_SYMBOL "__nxflat_abi_v2" +#define NXFLAT_ABI_MARKER __nxflat_abi_v2 + /**************************************************************************** * Public Types ****************************************************************************/ diff --git a/tools/.gitignore b/tools/.gitignore index 957b27157d54f..a30ce43ca8d3c 100644 --- a/tools/.gitignore +++ b/tools/.gitignore @@ -7,6 +7,7 @@ /gencromfs /initialconfig /mkconfig +/mknxflat /mkdeps /cnvwindeps /logparser diff --git a/tools/Makefile.host b/tools/Makefile.host index 3a2926cd659ed..c378a8d7daef4 100644 --- a/tools/Makefile.host +++ b/tools/Makefile.host @@ -39,14 +39,15 @@ all: b16$(HOSTEXEEXT) bdf-converter$(HOSTEXEEXT) cmpconfig$(HOSTEXEEXT) \ initialconfig$(HOSTEXEEXT) gencromfs$(HOSTEXEEXT) \ convert-comments$(HOSTEXEEXT) lowhex$(HOSTEXEEXT) \ detab$(HOSTEXEEXT) rmcr$(HOSTEXEEXT) incdir$(HOSTEXEEXT) \ - jlink-nuttx$(HOSTDYNEXT) + mknxflat$(HOSTEXEEXT) jlink-nuttx$(HOSTDYNEXT) default: mkconfig$(HOSTEXEEXT) mksyscall$(HOSTEXEEXT) mkdeps$(HOSTEXEEXT) \ cnvwindeps$(HOSTEXEEXT) incdir$(HOSTEXEEXT) ifdef HOSTEXEEXT .PHONY: b16 bdf-converter cmpconfig clean configure kconfig2html mkconfig \ mkdeps mksymtab mksyscall mkversion mkpasswd cnvwindeps nxstyle \ - initialconfig gencromfs convert-comments lowhex detab rmcr incdir + initialconfig gencromfs convert-comments lowhex detab rmcr incdir \ + mknxflat endif ifdef HOSTDYNEXT .PHONY: jlink-nuttx @@ -134,6 +135,18 @@ ifdef HOSTEXEEXT mksymtab: mksymtab$(HOSTEXEEXT) endif +# mknxflat - Generate the thunk file for an NXFLAT module + +MKNXFLAT_SRCS = nxflat/mknxflat.c nxflat/thunk_arm.c nxflat/thunk_thumb2.c + +mknxflat$(HOSTEXEEXT): $(MKNXFLAT_SRCS) + $(Q) $(HOSTCC) $(HOSTCFLAGS) -Inxflat -o mknxflat$(HOSTEXEEXT) \ + $(MKNXFLAT_SRCS) + +ifdef HOSTEXEEXT +mknxflat: mknxflat$(HOSTEXEEXT) +endif + # bdf-converter - Converts a BDF font to the NuttX font format bdf-converter$(HOSTEXEEXT): bdf-converter.c @@ -270,6 +283,8 @@ clean: $(call DELFILE, Make.dep) $(call DELFILE, mkconfig) $(call DELFILE, mkconfig.exe) + $(call DELFILE, mknxflat) + $(call DELFILE, mknxflat.exe) $(call DELFILE, mkdeps) $(call DELFILE, mkdeps.exe) $(call DELFILE, mksymtab) diff --git a/tools/Unix.mk b/tools/Unix.mk index 8424763d8d832..625772aaae862 100644 --- a/tools/Unix.mk +++ b/tools/Unix.mk @@ -286,6 +286,9 @@ tools/cnvwindeps$(HOSTEXEEXT): tools/mkpasswd$(HOSTEXEEXT): $(Q) $(MAKE) -C tools -f Makefile.host mkpasswd$(HOSTEXEEXT) +tools/mknxflat$(HOSTEXEEXT): + $(Q) $(MAKE) -C tools -f Makefile.host mknxflat$(HOSTEXEEXT) + # .dirlinks, and helpers # # Directories links. Most of establishing the NuttX configuration involves @@ -670,12 +673,20 @@ ifeq ($(CONFIG_BOARD_ETC_ROMFS_PASSWD_ENABLE),y) PASSWD_TOOL_DEP += tools/mkpasswd$(HOSTEXEEXT) endif -pass1dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT) $(PASSWD_TOOL_DEP) +# mknxflat generates the import thunks for an NXFLAT module, so it is only +# needed by a configuration that builds them. + +NXFLAT_TOOL_DEP = +ifeq ($(CONFIG_NXFLAT),y) +NXFLAT_TOOL_DEP += tools/mknxflat$(HOSTEXEEXT) +endif + +pass1dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT) $(PASSWD_TOOL_DEP) $(NXFLAT_TOOL_DEP) $(Q) for dir in $(USERDEPDIRS) ; do \ $(MAKE) -C $$dir depend || exit; \ done -pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT) $(PASSWD_TOOL_DEP) +pass2dep: context tools/mkdeps$(HOSTEXEEXT) tools/cnvwindeps$(HOSTEXEEXT) $(PASSWD_TOOL_DEP) $(NXFLAT_TOOL_DEP) $(Q) for dir in $(KERNDEPDIRS) ; do \ $(MAKE) -C $$dir EXTRAFLAGS="$(KDEFINE) $(EXTRAFLAGS)" depend || exit; \ done diff --git a/tools/nxflat/dyncall_skeleton_arm.def b/tools/nxflat/dyncall_skeleton_arm.def new file mode 100644 index 0000000000000..98b4cb21fdb66 --- /dev/null +++ b/tools/nxflat/dyncall_skeleton_arm.def @@ -0,0 +1,238 @@ +/*********************************************************************** + * tools/nxflat/dyncall_skeleton_arm.def + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***********************************************************************/ + +/******************************************************************* + * File Prologue + *******************************************************************/ + +static const char file_prologue[] = + "/*******************************************************************\n" + " *\n" + " * This file contains the dynamic call logic that performs the thunk\n" + " * for outound calls from one module to another.\n" + " *\n" + " * ARM register quick reference:\n" + " *\n" + " * Name Number ARM Procedure Calling Standard Role\n" + " *\n" + " * a1 r0 argument 1/integer result/scratch register/argc\n" + " * a2 r1 argument 2/scratch register/argv\n" + " * a3 r2 argument 3/scratch register/envp\n" + " * a4 r3 argument 4/scratch register\n" + " * v1 r4 register variable\n" + " * v2 r5 register variable\n" + " * v3 r6 register variable\n" + " * v4 r7 register variable\n" + " * v5 r8 register variable\n" + " * sb/v6 r9 static base/register variable\n" + " * sl/v7 r10 stack limit/stack chunk handle/reg. variable\n" + " * fp r11 frame pointer\n" + " * ip r12 scratch register/new-sb in inter-link-unit calls\n" + " * sp r13 lower end of current stack frame\n" + " * lr r14 link address/scratch register\n" + " * pc r15 program counter\n" + " *******************************************************************/\n\n" + "/*******************************************************************\n" + " * Included Files\n" + " *******************************************************************/\n\n" + "/*******************************************************************\n" + " * Definitions\n" + " *******************************************************************/\n\n" + "/* The __ARM_ARCH define is provided by gcc 4.8. Construct it otherwise. */\n" + "#ifndef __ARM_ARCH\n" + "# ifdef __ARM_ARCH_2__\n" + "# define __ARM_ARCH 2\n" + "# elif defined (__ARM_ARCH_3__) || defined (__ARM_ARCH_3M__)\n" + "# define __ARM_ARCH 3\n" + "# elif defined (__ARM_ARCH_4__) || defined (__ARM_ARCH_4T__)\n" + "# define __ARM_ARCH 4\n" + "# elif defined (__ARM_ARCH_5__) || defined (__ARM_ARCH_5E__) \\\n" + " || defined(__ARM_ARCH_5T__) || defined(__ARM_ARCH_5TE__) \\\n" + " || defined(__ARM_ARCH_5TEJ__)\n" + "# define __ARM_ARCH 5\n" + "# elif defined (__ARM_ARCH_6__) || defined(__ARM_ARCH_6J__) \\\n" + " || defined (__ARM_ARCH_6Z__) || defined(__ARM_ARCH_6ZK__) \\\n" + " || defined (__ARM_ARCH_6K__) || defined(__ARM_ARCH_6T2__)\n" + "# define __ARM_ARCH 6\n" + "# elif defined (__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__) \\\n" + " || defined(__ARM_ARCH_7R__) || defined(__ARM_ARCH_7M__) \\\n" + " || defined(__ARM_ARCH_7EM__)\n" + "# define __ARM_ARCH 7\n" + "# else\n" + "# error unknown arm architecture\n" + "# endif\n" + "#endif\n\n" + "#if __ARM_ARCH > 4 || defined (__ARM_ARCH_4T__)\n" + "# define ARCH_HAS_BX\n" + "#endif\n" + "#if __ARM_ARCH > 4\n" + "# define ARCH_HAS_BLX\n" + "#endif\n" + "#if defined(ARCH_HAS_BX)\n" + "#define BX(x) bx\t##x\n" + "#else\n" + "#define BX(x) mov\tpc, ##x\n" + "#endif\n\n"; + +static const char import_prologue[] = ""; + +/******************************************************************* + * Import Function Name String Table + *******************************************************************/ + +static const char import_name_strtab_prologue[] = + "\n/*******************************************************************\n" + " * Import Function Names\n" + " *******************************************************************/\n\n" + "/* These are the names of all of the functions that are imported.\n" + " * Notice that all data associated with the library names is retained\n" + " * in the .text section." + " */\n\n" + "\t.text\n" + "\t.align\t0\n"; + +#define MKIMPSTRTABARG(fn,i) (i), (i), (i), (fn), (i), (i) + +static const char import_name_strtab_format[] = + "\n\t.local\t__dynimport%04d\n" + "\t.type\t__dynimport%04d, object\n\n" + "__dynimport%04d:\n" + "\t.asciz\t\"%s\"\n" + "\t.size\t__dynimport%04d, .-__dynimport%04d\n"; + +/******************************************************************* + * Dynamic Call Information + *******************************************************************/ + +static const char dynimport_decl_prologue[] = + "\n/*******************************************************************\n" + " * Imported Symbol Table (an array of type struct flat_import)\n" + " *******************************************************************/\n\n" + "/* Notice that, unlike most other arrays in this file, this array\n" + " * is declared to reside in .data. Because of this, there will be\n" + " * per-process instances of this table.\n" + " */\n\n" + "\t.data\n" + "\t.align\t2\n\n" + "\t.global\t__dynimport_begin\n" + "\t.type\t__dynimport_begin, object\n" + "\t.global\t__dynimport_end\n" + "\t.type\t__dynimport_end, object\n\n"; + +#define MKINFODECLARGS(fn, i) (i), (fn), (i) + +static const char dynimport_decl_format[] = + "\t.local\t__dyninfo%04d\t/* Dynamic info for imported symbol %s */\n" + "\t.type\t__dyninfo%04d, object\n"; + +static const char dynimport_array_prologue[] = + "\n__dynimport_begin:\n"; + +#define MKINFOARGS(fn, i) (i), (fn), (i), (i), (i) + +static const char dynimport_array_format[] = + "__dyninfo%04d:\t\t\t/* Dynamic info for imported symbol %s */\n" + "\t.word\t__dynimport%04d\t/* Offset to name of imported function */\n" + "\t.word\t0\t\t/* Resolved address of imported function */\n" + "\t.size\t__dyninfo%04d, .-__dyninfo%04d\n"; + +static const char dynimport_array_epilogue[] = + "__dynimport_end:\n" + "\t.size\t__dynimport_begin, __dynimport_end-__dynimport_begin\n"; + +static const char dyncall_decl_prologue[] = + "\n/*******************************************************************\n" + " * Dynamic Call Logic\n" + " *******************************************************************/\n\n" + "\t.text\n" + "\t.align\t2\n"; + +#define MKCALLARGS(fn, i) (fn), (fn), (fn), (fn), (i), (i), (i), (fn), (fn) + +#ifndef __NO_GOT__ + +static const char dyncall_format[] = + "\n/* Dynamic call logic for imported symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tBX(ip)\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d(GOTOFF)\n" + "\t.size\t%s, .-%s\n"; + +static const char nonreturning_dyncall_format[] = + "\n/* Dynamic call logic for imported, non-returning symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tBX(ip)\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d(GOTOFF)\n" + "\t.size\t%s, .-%s\n"; + +#else + +static const char dyncall_format[] = + "\n/* Dynamic call logic for imported symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tBX(ip)\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d\n" + "\t.size\t%s, .-%s\n"; + +static const char nonreturning_dyncall_format[] = + "\n/* Dynamic call logic for imported, non-returning symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tBX(ip)\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d\n" + "\t.size\t%s, .-%s\n"; + +#endif + +/******************************************************************* + * File Epilogue + *******************************************************************/ + +static const char file_epilogue[] = + "\t.end\n"; + + + + diff --git a/tools/nxflat/dyncall_skeleton_thumb2.def b/tools/nxflat/dyncall_skeleton_thumb2.def new file mode 100644 index 0000000000000..5aa511739f24b --- /dev/null +++ b/tools/nxflat/dyncall_skeleton_thumb2.def @@ -0,0 +1,209 @@ +/*********************************************************************** + * tools/nxflat/dyncall_skeleton_thumb2.def + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ***********************************************************************/ + +/******************************************************************* + * File Prologue + *******************************************************************/ + +static const char file_prologue[] = + "/*******************************************************************\n" + " *\n" + " * This file contains the dynamic call logic that performs the thunk\n" + " * for outound calls from one module to another.\n" + " *\n" + " * ARM register quick reference:\n" + " *\n" + " * Name Number ARM Procedure Calling Standard Role\n" + " *\n" + " * a1 r0 argument 1/integer result/scratch register/argc\n" + " * a2 r1 argument 2/scratch register/argv\n" + " * a3 r2 argument 3/scratch register/envp\n" + " * a4 r3 argument 4/scratch register\n" + " * v1 r4 register variable\n" + " * v2 r5 register variable\n" + " * v3 r6 register variable\n" + " * v4 r7 register variable\n" + " * v5 r8 register variable\n" + " * sb/v6 r9 static base/register variable\n" + " * sl/v7 r10 stack limit/stack chunk handle/reg. variable\n" + " * fp r11 frame pointer\n" + " * ip r12 scratch register/new-sb in inter-link-unit calls\n" + " * sp r13 lower end of current stack frame\n" + " * lr r14 link address/scratch register\n" + " * pc r15 program counter\n" + " *******************************************************************/\n\n" + "\t.syntax\tunified\n" + "\t.thumb\n\n" + "/*******************************************************************\n" + " * Included Files\n" + " *******************************************************************/\n\n" + "/*******************************************************************\n" + " * Definitions\n" + " *******************************************************************/\n"; + +static const char import_prologue[] = ""; + +/******************************************************************* + * Import Function Name String Table + *******************************************************************/ + +static const char import_name_strtab_prologue[] = + "\n/*******************************************************************\n" + " * Import Function Names\n" + " *******************************************************************/\n\n" + "/* These are the names of all of the functions that are imported.\n" + " * Notice that all data associated with the library names is retained\n" + " * in the .text section." + " */\n\n" + "\t.text\n" + "\t.align\t0\n"; + +#define MKIMPSTRTABARG(fn,i) (i), (i), (i), (fn), (i), (i) + +static const char import_name_strtab_format[] = + "\n\t.local\t__dynimport%04d\n" + "\t.type\t__dynimport%04d, object\n\n" + "__dynimport%04d:\n" + "\t.asciz\t\"%s\"\n" + "\t.size\t__dynimport%04d, .-__dynimport%04d\n"; + +/******************************************************************* + * Dynamic Call Information + *******************************************************************/ + +static const char dynimport_decl_prologue[] = + "\n/*******************************************************************\n" + " * Imported Symbol Table (an array of type struct flat_import)\n" + " *******************************************************************/\n\n" + "/* Notice that, unlike most other arrays in this file, this array\n" + " * is declared to reside in .data. Because of this, there will be\n" + " * per-process instances of this table.\n" + " */\n\n" + "\t.data\n" + "\t.align\t2\n\n" + "\t.global\t__dynimport_begin\n" + "\t.type\t__dynimport_begin, object\n" + "\t.global\t__dynimport_end\n" + "\t.type\t__dynimport_end, object\n\n"; + +#define MKINFODECLARGS(fn, i) (i), (fn), (i) + +static const char dynimport_decl_format[] = + "\t.local\t__dyninfo%04d\t/* Dynamic info for imported symbol %s */\n" + "\t.type\t__dyninfo%04d, object\n"; + +static const char dynimport_array_prologue[] = + "\n__dynimport_begin:\n"; + +#define MKINFOARGS(fn, i) (i), (fn), (i), (i), (i) + +static const char dynimport_array_format[] = + "__dyninfo%04d:\t\t\t/* Dynamic info for imported symbol %s */\n" + "\t.word\t__dynimport%04d\t/* Offset to name of imported function */\n" + "\t.word\t0\t\t/* Resolved address of imported function */\n" + "\t.size\t__dyninfo%04d, .-__dyninfo%04d\n"; + +static const char dynimport_array_epilogue[] = + "__dynimport_end:\n" + "\t.size\t__dynimport_begin, __dynimport_end-__dynimport_begin\n"; + +static const char dyncall_decl_prologue[] = + "\n/*******************************************************************\n" + " * Dynamic Call Logic\n" + " *******************************************************************/\n\n" + "\t.text\n" + "\t.align\t2\n"; + +#define MKCALLARGS(fn, i) (fn), (fn), (fn), (fn), (i), (i), (i), (fn), (fn) + +#ifndef __NO_GOT__ + +static const char dyncall_format[] = + "\n/* Dynamic call logic for imported symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n" + "\t.thumb_func\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tbx\tip\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d(GOTOFF)\n" + "\t.size\t%s, .-%s\n"; + +static const char nonreturning_dyncall_format[] = + "\n/* Dynamic call logic for imported, non-returning symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n" + "\t.thumb_func\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tbx\tip\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d(GOTOFF)\n" + "\t.size\t%s, .-%s\n"; + +#else + +static const char dyncall_format[] = + "\n/* Dynamic call logic for imported symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n" + "\t.thumb_func\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tbx\tip\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d\n" + "\t.size\t%s, .-%s\n"; + +static const char nonreturning_dyncall_format[] = + "\n/* Dynamic call logic for imported, non-returning symbol %s */\n\n" + "\t.global\t%s\n" + "\t.type\t%s, function\n" + "\t.thumb_func\n\n" + "%s:\n" + "\tldr\tip,.Ldyn%04d\n" + "\tadd\tip,ip," NXFLAT_PIC_REG "\n" + "\tldr\tip,[ip,#4]\n" + "\tbx\tip\n" + ".Ldyn%04d:\n" + "\t.word\t__dyninfo%04d\n" + "\t.size\t%s, .-%s\n"; + +#endif + +/******************************************************************* + * File Epilogue + *******************************************************************/ + +static const char file_epilogue[] = + "\t.end\n"; + + + + diff --git a/tools/nxflat/mknxflat.c b/tools/nxflat/mknxflat.c new file mode 100644 index 0000000000000..467e2daa290fb --- /dev/null +++ b/tools/nxflat/mknxflat.c @@ -0,0 +1,767 @@ +/**************************************************************************** + * tools/nxflat/mknxflat.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * mknxflat generates the "thunk" assembly file for an NXFLAT module: one + * stub per imported function, plus the import name string table and the + * per-process __dyninfo array the loader fills in at load time. + * + * This is a port of the tool from the NuttX buildroot NXFLAT toolchain. + * The one substantive change is that the symbol table is read from the ELF + * file directly rather than through libbfd. libbfd is GPL, which an Apache + * project cannot depend on, and it is awkward to obtain besides -- but the + * dependency was never deep: the upstream tool used it only to open the + * file and enumerate symbols, never to relocate or rewrite anything. + * + * The emitted text is unchanged. The format strings live in the .def + * files, which are carried here byte-for-byte from upstream. + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "nxflat_thunk.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define dbg(format, ...) \ + do \ + { \ + if (verbose) \ + { \ + printf(format, ##__VA_ARGS__); \ + } \ + } \ + while (0) + +/* Just enough of the ELF32 ABI to walk a symbol table. Spelled out here + * rather than pulled from so the tool builds on any host. + */ + +#define EI_NIDENT 16 +#define ELFCLASS32 1 +#define ELFDATA2LSB 1 +#define ELFDATA2MSB 2 + +#define SHT_SYMTAB 2 +#define SHT_DYNSYM 11 + +#define SHN_UNDEF 0 + +#define STB_WEAK 2 +#define STT_OBJECT 1 + +#define ELF_ST_BIND(i) ((i) >> 4) +#define ELF_ST_TYPE(i) ((i) & 0x0f) + +#define MAX_EXPORT_NAMES 1024 + +/**************************************************************************** + * Private Types + ****************************************************************************/ + +struct elf32_ehdr_s +{ + unsigned char e_ident[EI_NIDENT]; + uint16_t e_type; + uint16_t e_machine; + uint32_t e_version; + uint32_t e_entry; + uint32_t e_phoff; + uint32_t e_shoff; + uint32_t e_flags; + uint16_t e_ehsize; + uint16_t e_phentsize; + uint16_t e_phnum; + uint16_t e_shentsize; + uint16_t e_shnum; + uint16_t e_shstrndx; +}; + +struct elf32_shdr_s +{ + uint32_t sh_name; + uint32_t sh_type; + uint32_t sh_flags; + uint32_t sh_addr; + uint32_t sh_offset; + uint32_t sh_size; + uint32_t sh_link; + uint32_t sh_info; + uint32_t sh_addralign; + uint32_t sh_entsize; +}; + +struct elf32_sym_s +{ + uint32_t st_name; + uint32_t st_value; + uint32_t st_size; + unsigned char st_info; + unsigned char st_other; + uint16_t st_shndx; +}; + +/* One imported symbol, in symbol table order */ + +struct import_s +{ + const char *name; + int is_object; + int is_weak; +}; + +typedef int (*namefunc_type)(const char *name, void *arg); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/* Command line settings (counters but treated like booleans) */ + +static int verbose = 0; +static int weak_imports = 0; +static int dsyms = 0; + +/* Characteristics of things */ + +static int calls_nonreturning_functions = 0; + +/* Names of things */ + +static const char *program_name = NULL; +static const char *elf_filename = NULL; +static const char *out_filename = NULL; + +/* The selected architecture's thunk format strings */ + +static const struct nxflat_thunk_s *thunk = NULL; + +/* The imported symbols, in symbol table order */ + +static struct import_s *imports = NULL; +static long number_undefined = 0; + +static int counter; + +/* Big-endian input? ARM is normally little-endian but big-endian ARM + * exists, so honour EI_DATA rather than assuming. + */ + +static int need_swap = 0; + +/**************************************************************************** + * Private constant data + ****************************************************************************/ + +/* This is the list of names of libc and libpthread functions that + * do not return. These may require some special handling -- at a + * minimum, they must tie up resources that can only be released + * when the function returns. + */ + +static const char *const nonreturners[] = +{ + "abort", /* Never returns */ + "exit", /* Never returns */ + "_exit", /* Never returns */ + "longjmp", /* Never returns */ + "_longjmp", /* Never returns */ + "pthread_exit", /* Never returns */ + "siglongjmp", /* Never returns */ + NULL +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: swap16 / swap32 + ****************************************************************************/ + +static uint16_t swap16(uint16_t v) +{ + return need_swap ? (uint16_t)((v >> 8) | (v << 8)) : v; +} + +static uint32_t swap32(uint32_t v) +{ + if (!need_swap) + { + return v; + } + + return ((v & 0x000000fful) << 24) | ((v & 0x0000ff00ul) << 8) | + ((v & 0x00ff0000ul) >> 8) | ((v & 0xff000000ul) >> 24); +} + +/**************************************************************************** + * Name: xread + * + * Description: + * Read exactly nbytes at an absolute offset, or die. + * + ****************************************************************************/ + +static void xread(int fd, void *buffer, size_t nbytes, off_t offset) +{ + ssize_t nread; + + if (lseek(fd, offset, SEEK_SET) == (off_t)-1) + { + fprintf(stderr, "%s: seek to %ld failed: %s\n", + elf_filename, (long)offset, strerror(errno)); + exit(2); + } + + while (nbytes > 0) + { + nread = read(fd, buffer, nbytes); + if (nread < 0) + { + if (errno == EINTR) + { + continue; + } + + fprintf(stderr, "%s: read failed: %s\n", + elf_filename, strerror(errno)); + exit(2); + } + else if (nread == 0) + { + fprintf(stderr, "%s: unexpected end of file\n", elf_filename); + exit(2); + } + + buffer = (char *)buffer + nread; + nbytes -= nread; + } +} + +/**************************************************************************** + * Name: load_imports + * + * Description: + * Collect every undefined, non-object symbol from the ELF file, in symbol + * table order. + * + * The selection rule is the upstream one. Symbol typing is not + * trustworthy here: imported functions are frequently emitted as + * STT_NOTYPE rather than STT_FUNC, while a weakly defined *object* does + * show up as an undefined object. So rather than looking for functions, + * this takes everything undefined that is not explicitly an object. A + * genuinely undefined object would be an error, and is left to the link. + * + ****************************************************************************/ + +static void load_imports(void) +{ + struct elf32_ehdr_s ehdr; + struct elf32_shdr_s *shdrs; + struct elf32_sym_s *syms; + char *strtab; + int wanted = dsyms ? SHT_DYNSYM : SHT_SYMTAB; + int symidx = -1; + size_t nsyms; + size_t strsize; + size_t i; + uint16_t probe; + int host_le; + int obj_le; + int fd; + + fd = open(elf_filename, O_RDONLY); + if (fd < 0) + { + fprintf(stderr, "%s: cannot open: %s\n", + elf_filename, strerror(errno)); + exit(2); + } + + xread(fd, &ehdr, sizeof(ehdr), 0); + + if (memcmp(ehdr.e_ident, "\177ELF", 4) != 0) + { + fprintf(stderr, "%s: not an ELF file\n", elf_filename); + exit(2); + } + + if (ehdr.e_ident[4] != ELFCLASS32) + { + fprintf(stderr, "%s: not a 32-bit ELF file\n", elf_filename); + exit(2); + } + + /* Decide whether the host and the object disagree about byte order */ + + probe = 1; + host_le = *(const unsigned char *)&probe; + obj_le = (ehdr.e_ident[5] == ELFDATA2LSB); + + need_swap = (host_le != obj_le); + + /* Re-read the fields that mattered now that byte order is known */ + + ehdr.e_shoff = swap32(ehdr.e_shoff); + ehdr.e_shnum = swap16(ehdr.e_shnum); + ehdr.e_shentsize = swap16(ehdr.e_shentsize); + + if (ehdr.e_shnum == 0 || ehdr.e_shentsize != sizeof(struct elf32_shdr_s)) + { + fprintf(stderr, "%s: no usable section header table\n", elf_filename); + exit(2); + } + + shdrs = malloc((size_t)ehdr.e_shnum * sizeof(struct elf32_shdr_s)); + if (shdrs == NULL) + { + fprintf(stderr, "Failed to allocate section headers\n"); + exit(3); + } + + xread(fd, shdrs, (size_t)ehdr.e_shnum * sizeof(struct elf32_shdr_s), + ehdr.e_shoff); + + for (i = 0; i < ehdr.e_shnum; i++) + { + shdrs[i].sh_type = swap32(shdrs[i].sh_type); + shdrs[i].sh_offset = swap32(shdrs[i].sh_offset); + shdrs[i].sh_size = swap32(shdrs[i].sh_size); + shdrs[i].sh_link = swap32(shdrs[i].sh_link); + shdrs[i].sh_entsize = swap32(shdrs[i].sh_entsize); + + if ((int)shdrs[i].sh_type == wanted && symidx < 0) + { + symidx = (int)i; + } + } + + if (symidx < 0) + { + fprintf(stderr, "%s: no %s section\n", elf_filename, + dsyms ? "dynamic symbol table" : "symbol table"); + exit(2); + } + + if (shdrs[symidx].sh_entsize != sizeof(struct elf32_sym_s)) + { + fprintf(stderr, "%s: unexpected symbol entry size\n", elf_filename); + exit(2); + } + + nsyms = shdrs[symidx].sh_size / sizeof(struct elf32_sym_s); + + syms = malloc(shdrs[symidx].sh_size); + if (syms == NULL) + { + fprintf(stderr, "Failed to allocate symbol table\n"); + exit(3); + } + + xread(fd, syms, shdrs[symidx].sh_size, shdrs[symidx].sh_offset); + + /* The linked string table holds the names */ + + if (shdrs[symidx].sh_link >= ehdr.e_shnum) + { + fprintf(stderr, "%s: symbol table has no string table\n", + elf_filename); + exit(2); + } + + strsize = shdrs[shdrs[symidx].sh_link].sh_size; + strtab = malloc(strsize + 1); + if (strtab == NULL) + { + fprintf(stderr, "Failed to allocate string table\n"); + exit(3); + } + + xread(fd, strtab, strsize, shdrs[shdrs[symidx].sh_link].sh_offset); + strtab[strsize] = '\0'; + + close(fd); + + imports = calloc(nsyms + 1, sizeof(struct import_s)); + if (imports == NULL) + { + fprintf(stderr, "Failed to allocate import table\n"); + exit(3); + } + + /* The ABI marker goes first, so that every module has at least one + * import and the loader can tell what it was built for. It is a marker + * rather than a real import: nothing calls it and no board exports it -- + * the loader matches it by name and skips resolution. + */ + + imports[0].name = NXFLAT_ABI_SYMBOL; + imports[0].is_object = 0; + imports[0].is_weak = 0; + number_undefined = 1; + + for (i = 0; i < nsyms; i++) + { + uint32_t st_name = swap32(syms[i].st_name); + uint32_t st_value = swap32(syms[i].st_value); + uint16_t st_shndx = swap16(syms[i].st_shndx); + unsigned char info = syms[i].st_info; + + if (st_shndx != SHN_UNDEF || st_value != 0 || st_name == 0 || + st_name >= strsize) + { + continue; + } + + if (ELF_ST_TYPE(info) == STT_OBJECT) + { + /* An undefined object is not something a thunk can stand in + * for; leave it to the link to complain. + */ + + continue; + } + + imports[number_undefined].name = &strtab[st_name]; + imports[number_undefined].is_object = 0; + imports[number_undefined].is_weak = + (ELF_ST_BIND(info) == STB_WEAK); + number_undefined++; + } + + free(shdrs); + free(syms); + + dbg("Found %ld undefined symbols\n", number_undefined); +} + +/**************************************************************************** + * Name: traverse_undefined_functions + ****************************************************************************/ + +static int traverse_undefined_functions(void *arg, namefunc_type fn) +{ + long i; + + for (i = 0; i < number_undefined; i++) + { + /* Is it imported as a "weak" symbol? If so, we will process the + * symbol only if we were requested to do so from the command line. + */ + + if (imports[i].is_weak && weak_imports == 0) + { + continue; + } + + if (fn(imports[i].name, arg) != 0) + { + return 1; + } + } + + return 0; +} + +/**************************************************************************** + * Name: put_string + ****************************************************************************/ + +static void put_string(int fd, const char *string) +{ + ssize_t bytes_available = strlen(string); + ssize_t bytes_written = write(fd, string, bytes_available); + + if (bytes_written < 0) + { + fprintf(stderr, + "Failed to write %ld bytes of string to output, errno=%d\n", + (long)bytes_available, errno); + exit(5); + } + else if (bytes_written != bytes_available) + { + fprintf(stderr, "Only wrote %ld of %ld bytes of string to output\n", + (long)bytes_written, (long)bytes_available); + exit(6); + } +} + +/**************************************************************************** + * Name: does_not_return_name + ****************************************************************************/ + +static int does_not_return_name(const char *func_name) +{ + int i; + + for (i = 0; nonreturners[i] != NULL; i++) + { + if (strcmp(func_name, nonreturners[i]) == 0) + { + return 1; + } + } + + return 0; +} + +static int check_nonreturning(const char *func_name, void *arg) +{ + if (does_not_return_name(func_name)) + { + calls_nonreturning_functions = 1; + } + + return 0; +} + +/**************************************************************************** + * Name: put_import_name_strtab / put_dynimport_decl / ... + * + * Description: + * The four emission passes. Each walks the import list in the same + * order, so the %04d counters line up across passes. + * + ****************************************************************************/ + +static int put_import_name(const char *func_name, void *arg) +{ + char buffer[4096]; + int fd = *(int *)arg; + + snprintf(buffer, sizeof(buffer), thunk->import_name_strtab_format, + counter, counter, counter, func_name, counter, counter); + put_string(fd, buffer); + counter++; + return 0; +} + +static int put_dynimport_decl(const char *func_name, void *arg) +{ + char buffer[4096]; + int fd = *(int *)arg; + + snprintf(buffer, sizeof(buffer), thunk->dynimport_decl_format, + counter, func_name, counter); + put_string(fd, buffer); + counter++; + return 0; +} + +static int put_dynimport_array(const char *func_name, void *arg) +{ + char buffer[4096]; + int fd = *(int *)arg; + + snprintf(buffer, sizeof(buffer), thunk->dynimport_array_format, + counter, func_name, counter, counter, counter); + put_string(fd, buffer); + counter++; + return 0; +} + +static int put_dyncall(const char *func_name, void *arg) +{ + char buffer[4096]; + int fd = *(int *)arg; + const char *format; + + if (does_not_return_name(func_name)) + { + format = thunk->nonreturning_dyncall_format; + } + else + { + format = thunk->dyncall_format; + } + + snprintf(buffer, sizeof(buffer), format, + func_name, func_name, func_name, func_name, + counter, counter, counter, func_name, func_name); + put_string(fd, buffer); + counter++; + return 0; +} + +/**************************************************************************** + * Name: show_usage + ****************************************************************************/ + +static void show_usage(void) +{ + fprintf(stderr, "Usage: %s [options] \n\n", program_name); + fprintf(stderr, "Where options are one or more of the following. Note\n"); + fprintf(stderr, "that a space is always required between the\n"); + fprintf(stderr, "option and any following arguments.\n\n"); + fprintf(stderr, " -a \n"); + fprintf(stderr, " Instruction set of the module: arm or thumb2\n"); + fprintf(stderr, " [thumb2]\n"); + fprintf(stderr, " -d Use dynamic symbol table. [symtab]\n"); + fprintf(stderr, " -o \n"); + fprintf(stderr, " Output to [stdout]\n"); + fprintf(stderr, " -v Verbose output [no output]\n"); + fprintf(stderr, " -w Import weakly declared functions, i.e., weakly\n"); + fprintf(stderr, " declared functions are expected to be\n"); + fprintf(stderr, " provided at load-time [not imported]\n"); + fprintf(stderr, "\n"); + exit(1); +} + +/**************************************************************************** + * Name: parse_args + ****************************************************************************/ + +static void parse_args(int argc, char **argv) +{ + const char *arch = "thumb2"; + int opt; + + program_name = argv[0]; + + while ((opt = getopt(argc, argv, "a:do:vw")) != -1) + { + switch (opt) + { + case 'a': + arch = optarg; + break; + + case 'd': + dsyms++; + break; + + case 'o': + out_filename = optarg; + break; + + case 'v': + verbose++; + break; + + case 'w': + weak_imports++; + break; + + default: + show_usage(); + break; + } + } + + if (strcmp(arch, "thumb2") == 0) + { + thunk = &g_thunk_thumb2; + } + else if (strcmp(arch, "arm") == 0) + { + thunk = &g_thunk_arm; + } + else + { + fprintf(stderr, "Unrecognized architecture '%s'\n\n", arch); + show_usage(); + } + + if (optind >= argc) + { + fprintf(stderr, "No ELF file provided\n\n"); + show_usage(); + } + + elf_filename = argv[optind]; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int main(int argc, char **argv, char **envp) +{ + int fd = 1; + + parse_args(argc, argv); + + if (out_filename != NULL) + { + fd = open(out_filename, O_WRONLY | O_CREAT | O_TRUNC, 0644); + if (fd < 0) + { + fprintf(stderr, "Failed to open %s: %s\n", out_filename, + strerror(errno)); + exit(4); + } + } + + load_imports(); + + traverse_undefined_functions(NULL, check_nonreturning); + + /* Output the thunk file in the same order the upstream tool used: + * prologue, import name string table, the __dyninfo declarations, the + * __dyninfo array, then the call thunks. + */ + + put_string(fd, thunk->file_prologue); + put_string(fd, thunk->import_prologue); + + put_string(fd, thunk->import_name_strtab_prologue); + counter = 0; + traverse_undefined_functions(&fd, put_import_name); + + put_string(fd, thunk->dynimport_decl_prologue); + counter = 0; + traverse_undefined_functions(&fd, put_dynimport_decl); + + put_string(fd, thunk->dynimport_array_prologue); + counter = 0; + traverse_undefined_functions(&fd, put_dynimport_array); + put_string(fd, thunk->dynimport_array_epilogue); + + put_string(fd, thunk->dyncall_decl_prologue); + counter = 0; + traverse_undefined_functions(&fd, put_dyncall); + + put_string(fd, thunk->file_epilogue); + + if (fd != 1) + { + close(fd); + } + + return 0; +} diff --git a/tools/nxflat/nxflat_thunk.h b/tools/nxflat/nxflat_thunk.h new file mode 100644 index 0000000000000..b466279ca5bd9 --- /dev/null +++ b/tools/nxflat/nxflat_thunk.h @@ -0,0 +1,91 @@ +/**************************************************************************** + * tools/nxflat/nxflat_thunk.h + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +#ifndef __TOOLS_NXFLAT_NXFLAT_THUNK_H +#define __TOOLS_NXFLAT_NXFLAT_THUNK_H + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* The register a module reaches its own data through, named here once so + * the thunk stubs and arch/arm cannot drift apart. It must agree with + * PIC_REG in arch/arm/include/arch.h and with -mpic-register in + * arch/arm/src/common/Toolchain.defs: a module whose data accesses use one + * register and whose import thunks add another will load, and then branch + * to a wild address on its first call out. + */ + +#define NXFLAT_PIC_REG "r9" + +/* Every module declares the module ABI it was built for by importing this + * name, and the loader refuses a module that does not. That is the only + * version channel available: the NXFLAT header has no version field, and + * h_magic is written by ldnxflat, which is GPL and stays out of the + * repository, so it can never be changed in step with the loader. The + * import table can, because mknxflat emits it and nxflat_bindimports() + * reads it, and ldnxflat passes it through untouched. + * + * Must match NXFLAT_ABI_SYMBOL in include/nxflat.h. + */ + +#define NXFLAT_ABI_SYMBOL "__nxflat_abi_v2" + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* The set of format strings that make up one architecture's thunk file. + * + * The upstream tool selected these at compile time through an "arch" + * symlink pointing at either arm/ or thumb2/. A symlink cannot be carried + * in the repository, and one host binary has to serve boards of both + * flavours -- lpc31xx is ARM while lpc17xx, tiva, stm32f1 and rp23xx are + * Thumb-2 -- so the choice moves to a runtime "-a" option instead. The + * .def files themselves are unmodified, so the emitted text is unchanged. + */ + +struct nxflat_thunk_s +{ + const char *file_prologue; + const char *import_prologue; + const char *import_name_strtab_prologue; + const char *import_name_strtab_format; + const char *dynimport_decl_prologue; + const char *dynimport_decl_format; + const char *dynimport_array_prologue; + const char *dynimport_array_format; + const char *dynimport_array_epilogue; + const char *dyncall_decl_prologue; + const char *dyncall_format; + const char *nonreturning_dyncall_format; + const char *file_epilogue; +}; + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +extern const struct nxflat_thunk_s g_thunk_arm; +extern const struct nxflat_thunk_s g_thunk_thumb2; + +#endif /* __TOOLS_NXFLAT_NXFLAT_THUNK_H */ diff --git a/tools/nxflat/thunk_arm.c b/tools/nxflat/thunk_arm.c new file mode 100644 index 0000000000000..2957ed0cf8523 --- /dev/null +++ b/tools/nxflat/thunk_arm.c @@ -0,0 +1,63 @@ +/**************************************************************************** + * tools/nxflat/thunk_arm.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "nxflat_thunk.h" + +/* The format strings have file scope inside the .def, so each + * architecture gets its own translation unit and the two sets cannot + * collide. The .def is the upstream file, less one comment typo. + */ + +#include "dyncall_skeleton_arm.def" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* None: this translation unit exists only to give one architecture's + * format strings a scope of their own. + */ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +const struct nxflat_thunk_s g_thunk_arm = +{ + file_prologue, + import_prologue, + import_name_strtab_prologue, + import_name_strtab_format, + dynimport_decl_prologue, + dynimport_decl_format, + dynimport_array_prologue, + dynimport_array_format, + dynimport_array_epilogue, + dyncall_decl_prologue, + dyncall_format, + nonreturning_dyncall_format, + file_epilogue +}; diff --git a/tools/nxflat/thunk_thumb2.c b/tools/nxflat/thunk_thumb2.c new file mode 100644 index 0000000000000..c4b1f25e92732 --- /dev/null +++ b/tools/nxflat/thunk_thumb2.c @@ -0,0 +1,63 @@ +/**************************************************************************** + * tools/nxflat/thunk_thumb2.c + * + * SPDX-License-Identifier: Apache-2.0 + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "nxflat_thunk.h" + +/* The format strings have file scope inside the .def, so each + * architecture gets its own translation unit and the two sets cannot + * collide. The .def is the upstream file, less one comment typo. + */ + +#include "dyncall_skeleton_thumb2.def" + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/* None: this translation unit exists only to give one architecture's + * format strings a scope of their own. + */ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +const struct nxflat_thunk_s g_thunk_thumb2 = +{ + file_prologue, + import_prologue, + import_name_strtab_prologue, + import_name_strtab_format, + dynimport_decl_prologue, + dynimport_decl_format, + dynimport_array_prologue, + dynimport_array_format, + dynimport_array_epilogue, + dyncall_decl_prologue, + dyncall_format, + nonreturning_dyncall_format, + file_epilogue +};