Commit 8ce758a8 authored by Daniel Leung's avatar Daniel Leung Committed by Anas Nashif
Browse files

linker: warn about orphan sections



This adds a linker flag and necessary changes to linker scripts
so that linker will warn about orphan sections.

Relates to #5534.

Signed-off-by: default avatarDaniel Leung <daniel.leung@intel.com>
parent 08c165f2
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -287,6 +287,13 @@ zephyr_ld_options(
  ${LINKERFLAGPREFIX},--build-id=none
  )

# Funny thing is if this is set to =error, some architectures will
# skip this flag even though the compiler flag check passes
# (e.g. ARC and Xtensa). So keep it at =warn, for now.
zephyr_ld_options(
  ${LINKERFLAGPREFIX},--orphan-handling=warn
  )

if(CONFIG_HAVE_CUSTOM_LINKER_SCRIPT)
  set(LINKER_SCRIPT ${APPLICATION_SOURCE_DIR}/${CONFIG_CUSTOM_LINKER_SCRIPT})
  if(NOT EXISTS ${LINKER_SCRIPT})
+6 −0
Original line number Diff line number Diff line
@@ -73,6 +73,9 @@ MEMORY {
}

SECTIONS {

#include <linker/rel-sections.ld>

	GROUP_START(ROMABLE_REGION)

	SECTION_PROLOGUE(_TEXT_SECTION_NAME,,ALIGN(1024)) {
@@ -283,4 +286,7 @@ SECTIONS {
#ifdef CONFIG_GEN_ISR_TABLES
#include <linker/intlist.ld>
#endif

#include <linker/debug-sections.ld>

	}
+45 −0
Original line number Diff line number Diff line
@@ -87,6 +87,23 @@ ENTRY(CONFIG_KERNEL_ENTRY)

SECTIONS
    {

#include <linker/rel-sections.ld>

    /*
     * .plt and .iplt are here according to 'arm-zephyr-elf-ld --verbose',
     * before text section.
     */
    SECTION_PROLOGUE(.plt,,)
	{
	*(.plt)
	}

    SECTION_PROLOGUE(.iplt,,)
	{
	*(.iplt)
	}

    GROUP_START(ROMABLE_REGION)

	_image_rom_start = ROM_ADDR;
@@ -133,6 +150,12 @@ SECTIONS
	*(".text.*")
	*(.gnu.linkonce.t.*)

	/*
	 * These are here according to 'arm-zephyr-elf-ld --verbose',
	 * after .gnu.linkonce.t.*
	 */
	*(.glue_7t) *(.glue_7) *(.vfp11_veneer) *(.v4_bx)

#include <linker/priv_stacks-text.ld>
#include <linker/kobject-text.ld>

@@ -219,6 +242,18 @@ SECTIONS
    } > FLASH_CCFG
#endif

    /*
     * These are here according to 'arm-zephyr-elf-ld --verbose',
     * before data section.
     */
    SECTION_PROLOGUE(.got,,)
	{
	*(.got.plt)
	*(.igot.plt)
	*(.got)
	*(.igot)
	}

    GROUP_START(RAMABLE_REGION)


@@ -319,6 +354,8 @@ SECTIONS
	KERNEL_INPUT_SECTION(COMMON)
	*(".kernel_bss.*")

#include <linker/priv_stacks-noinit.ld>

        /*
         * As memory is cleared in words only, it is simpler to ensure the BSS
         * section ends on a 4 byte boundary. This wastes a maximum of 3 bytes.
@@ -427,4 +464,12 @@ SECTIONS
#include <linker/intlist.ld>
#endif

#include <linker/debug-sections.ld>

    SECTION_PROLOGUE(.ARM.attributes, 0,)
	{
	KEEP(*(.ARM.attributes))
	KEEP(*(.gnu.attributes))
	}

    }
+19 −0
Original line number Diff line number Diff line
@@ -82,6 +82,23 @@ ENTRY(CONFIG_KERNEL_ENTRY)

SECTIONS
    {

#include <linker/rel-sections.ld>

    /*
     * .plt and .iplt are here according to
     * 'nios2-zephyr-elf-ld --verbose', before text section.
     */
    SECTION_PROLOGUE(.plt,,)
        {
        *(.plt)
        }

    SECTION_PROLOGUE(.iplt,,)
        {
        *(.iplt)
        }

    GROUP_START(ROMABLE_REGION)
    _image_rom_start = _ROM_ADDR;

@@ -261,5 +278,7 @@ SECTIONS
#include <linker/intlist.ld>
#endif

#include <linker/debug-sections.ld>

    }
+27 −0
Original line number Diff line number Diff line
@@ -21,16 +21,43 @@
#include <linker/linker-defs.h>
#include <linker/linker-tool.h>

SECTIONS
 {
	SECTION_PROLOGUE(.note.ABI-tag,,)
	{
	*(.note.ABI-tag)
	}

 } INSERT AFTER .interp;

SECTIONS
 {

#include <linker/rel-sections.ld>

#include <linker/common-rom.ld>

#include <linker/common-ram.ld>

	SECTION_PROLOGUE(_NOINIT_SECTION_NAME, (NOLOAD OPTIONAL),)
	{
	/*
	 * This section is used for non-initialized objects that
	 * will not be cleared during the boot process.
	 */
	KERNEL_INPUT_SECTION(.noinit)
	KERNEL_INPUT_SECTION(".noinit.*")
	*(".kernel_noinit.*")
	}

#include <arch/posix/native_tasks.ld>

	/* Related to transactional memory */
	SECTION_PROLOGUE(.tm_clone_table,,)
	{
	*(.tm_clone_table)
	}

 __data_ram_end = .;

 } INSERT AFTER .data;
Loading