ARM: Define custom ELF headers for ARM.
At least when building with the gnu toolchain, the headers the linker automatically generate save space for the actual ELF headers in one of the loadable segments. This creates two problems. First, the data you intended to be at the start of the image doesn't actually show up there, it's actually the ELF headers. Second, the ELF headers are essentially useless for firmware since there's currently nothing to tell you where they are, and even if there was, there isn't much of a reason to look at them. They're useful in userspace for, for instance, the dynamic linker, but not really in firmware. This change adds a PHDRS construct to each of the linker scripts used on ARM which define a single segment called to_load which does not have the flag set which would tell the linker to put headers in it. The first section defined in the script has ": to_load" to tell the linker which segment to put it in, and from that point on the other sections go in there by default. BUG=None TEST=Built and booted on nyan. Verified that the ROM stage was less than 18KB. Reverted the change which forced ROM stage alignment and saw that the ROM stage stayed the same size. BRANCH=None Change-Id: Ie2670f33f0421b16b2d4663fbfa99358890c77e4 Signed-off-by: Gabe Black <gabeblack@google.com> Reviewed-on: https://chromium-review.googlesource.com/180163 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Tom Warren <twarren@nvidia.com> Reviewed-by: Stefan Reinauer <reinauer@chromium.org> Commit-Queue: Gabe Black <gabeblack@chromium.org> Tested-by: Gabe Black <gabeblack@chromium.org>
This commit is contained in:
parent
cf26be4cb5
commit
62635c74b9
3 changed files with 18 additions and 3 deletions
|
|
@ -23,6 +23,11 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
|||
OUTPUT_ARCH(arm)
|
||||
INCLUDE ldoptions
|
||||
|
||||
PHDRS
|
||||
{
|
||||
to_load PT_LOAD;
|
||||
}
|
||||
|
||||
ENTRY(_start)
|
||||
TARGET(binary)
|
||||
SECTIONS
|
||||
|
|
@ -42,7 +47,7 @@ SECTIONS
|
|||
*(.bss.*);
|
||||
*(.sbss);
|
||||
*(.sbss.*);
|
||||
} = 0xff
|
||||
} : to_load = 0xff
|
||||
|
||||
/DISCARD/ : {
|
||||
*(.comment)
|
||||
|
|
|
|||
|
|
@ -22,6 +22,11 @@
|
|||
/* We use ELF as output format. So that we can debug the code in some form. */
|
||||
INCLUDE ldoptions
|
||||
|
||||
PHDRS
|
||||
{
|
||||
to_load PT_LOAD;
|
||||
}
|
||||
|
||||
ENTRY(stage_entry)
|
||||
|
||||
SECTIONS
|
||||
|
|
@ -38,7 +43,7 @@ SECTIONS
|
|||
*(.text.*);
|
||||
. = ALIGN(16);
|
||||
_etext = .;
|
||||
}
|
||||
} : to_load
|
||||
|
||||
.ctors : {
|
||||
. = ALIGN(0x100);
|
||||
|
|
|
|||
|
|
@ -29,6 +29,11 @@ OUTPUT_FORMAT("elf32-littlearm", "elf32-littlearm", "elf32-littlearm")
|
|||
OUTPUT_ARCH(arm)
|
||||
INCLUDE ldoptions
|
||||
|
||||
PHDRS
|
||||
{
|
||||
to_load PT_LOAD;
|
||||
}
|
||||
|
||||
ENTRY(stage_entry)
|
||||
|
||||
SECTIONS
|
||||
|
|
@ -41,7 +46,7 @@ SECTIONS
|
|||
*(.text.startup);
|
||||
*(.text);
|
||||
*(.text.*);
|
||||
}
|
||||
} : to_load
|
||||
|
||||
.romdata . : {
|
||||
*(.rodata);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue