Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 023bf6f1 authored by Tejun Heo's avatar Tejun Heo
Browse files

linker script: unify usage of discard definition



Discarded sections in different archs share some commonality but have
considerable differences.  This led to linker script for each arch
implementing its own /DISCARD/ definition, which makes maintaining
tedious and adding new entries error-prone.

This patch makes all linker scripts to move discard definitions to the
end of the linker script and use the common DISCARDS macro.  As ld
uses the first matching section definition, archs can include default
discarded sections by including them earlier in the linker script.

ia64 is notable because it first throws away some ia64 specific
subsections and then include the rest of the sections into the final
image, so those sections must be discarded before the inclusion.

defconfig compile tested for x86, x86-64, powerpc, powerpc64, ia64,
alpha, sparc, sparc64 and s390.  Michal Simek tested microblaze.

Signed-off-by: default avatarTejun Heo <tj@kernel.org>
Acked-by: default avatarPaul Mundt <lethal@linux-sh.org>
Acked-by: default avatarMike Frysinger <vapier@gentoo.org>
Tested-by: default avatarMichal Simek <monstr@monstr.eu>
Cc: linux-arch@vger.kernel.org
Cc: Michal Simek <monstr@monstr.eu>
Cc: microblaze-uclinux@itee.uq.edu.au
Cc: Sam Ravnborg <sam@ravnborg.org>
Cc: Tony Luck <tony.luck@intel.com>
parent 1dcdd091
Loading
Loading
Loading
Loading
+2 −8
Original line number Diff line number Diff line
@@ -134,14 +134,6 @@ SECTIONS
	__bss_stop = .;
	_end = .;

	/* Sections to be discarded */
	/DISCARD/ : {
		EXIT_TEXT
		EXIT_DATA
		*(.exitcall.exit)
		*(.discard)
	}

	.mdebug 0 : {
		*(.mdebug)
	}
@@ -151,4 +143,6 @@ SECTIONS

	STABS_DEBUG
	DWARF_DEBUG

	DISCARDS
}
+3 −7
Original line number Diff line number Diff line
@@ -124,15 +124,11 @@ SECTIONS
		_end = .;
	}

	DWARF_DEBUG

	/* When something in the kernel is NOT compiled as a module, the module
	 * cleanup code and data are put into these segments. Both can then be
	 * thrown away, as cleanup code is never called unless it's a module.
	 */
	/DISCARD/       	: {
		EXIT_DATA
		*(.exitcall.exit)
		*(.discard)
	}

	DWARF_DEBUG
	DISCARDS
}
+1 −5
Original line number Diff line number Diff line
@@ -277,9 +277,5 @@ SECTIONS

	DWARF_DEBUG

	/DISCARD/ :
	{
		*(.exitcall.exit)
		*(.discard)
	}
	DISCARDS
}
+2 −8
Original line number Diff line number Diff line
@@ -140,13 +140,7 @@ SECTIONS
	_end = .;
	__end = .;

	/* Sections to be discarded */
	/DISCARD/ : {
		EXIT_TEXT
		EXIT_DATA
		*(.exitcall.exit)
		*(.discard)
        }

	dram_end = dram_start + (CONFIG_ETRAX_DRAM_SIZE - __CONFIG_ETRAX_VMEM_SIZE)*1024*1024;

	DISCARDS
}
+1 −1
Original line number Diff line number Diff line
@@ -178,7 +178,7 @@ SECTIONS

  .comment 0 : { *(.comment) }

  /DISCARD/ : { *(.discard) }
  DISCARDS
}

__kernel_image_size_no_bss = __bss_start - __kernel_image_start;
Loading