diff options
author | Jens Wiklander <jens.wiklander@linaro.org> | 2017-05-25 07:48:20 +0200 |
---|---|---|
committer | Jens Wiklander <jens.wiklander@linaro.org> | 2017-05-29 10:09:23 +0200 |
commit | 5976a0a5b9bf7aaebe65320eb5e1709f7bd1f04e (patch) | |
tree | e527e9ec06e1eef9c2a60fccc8d4b8531a414b69 /scripts | |
parent | ce0d8e2da340980ac3f70aaa1122876308d0f745 (diff) |
core: avoid incremental linking with -gc
The AArch64 linkers seems to have occasional problems with incremental
linking (-i) in combination with garbage collect of sections (-gc). The
way we're organizing the layout of the binary used for paging depends on
-gc to build the different dependency trees for unpaged and
initialization code.
The problem in the linker is tracked in
https://bugs.linaro.org/show_bug.cgi?id=3006 and
https://sourceware.org/bugzilla/show_bug.cgi?id=21524
The problem typically manifests itself by:
aarch64-toolchain/gcc-linaro-6.3.1-2017.02-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-ld: BFD (Linaro_Binutils-2017.02) 2.27.0.20161019 assertion fail /home/tcwg-buildslave/workspace/tcwg-make-release/label/docker-trusty-amd64-tcwg-build/target/aarch64-linux-gnu/snapshots/binutils-gdb.git~linaro_binutils-2_27-branch/bfd/elflink.c:8380
core/arch/arm/kernel/link.mk:90: recipe for target 'out/arm-plat-vexpress/core/init.o' failed
make: *** [out/arm-plat-vexpress/core/init.o] Error 1
With this patch we replace the incremental linking with a full link
using a special link script. With a full link we can't have undefined
symbols so some dummy symbols are provided by the link script when some
object files are skipped when reducing the dependency tree. To
completely get rid of those dummy symbols the script that gathers the
sections is replaced by a python script that skips listed sections (if
provided).
In terms of features in the resulting binary, nothing is changed in this
commit.
Reviewed-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Acked-by: Jerome Forissier <jerome.forissier@linaro.org>
Signed-off-by: Jens Wiklander <jens.wiklander@linaro.org>
Diffstat (limited to 'scripts')
-rwxr-xr-x[-rw-r--r--] | scripts/gen_ld_sects.py (renamed from scripts/gen_ld_rodata_sects.awk) | 86 | ||||
-rw-r--r-- | scripts/gen_ld_text_sects.awk | 55 |
2 files changed, 57 insertions, 84 deletions
diff --git a/scripts/gen_ld_rodata_sects.awk b/scripts/gen_ld_sects.py index 04e59925..ea8b2749 100644..100755 --- a/scripts/gen_ld_rodata_sects.awk +++ b/scripts/gen_ld_sects.py @@ -1,5 +1,6 @@ +#!/usr/bin/env python # -# Copyright (c) 2014, Linaro Limited +# Copyright (c) 2017, Linaro Limited # All rights reserved. # # Redistribution and use in source and binary forms, with or without @@ -25,31 +26,58 @@ # POSSIBILITY OF SUCH DAMAGE. # -BEGIN { - in_shdr = 0; -} - -/Section Headers:/ { - in_shdr = 1; - next; -} - -/Key to Flags:/ { - in_shdr = 0; - next; -} - -{ - if (in_shdr) { - if ($1 == "[") - name_offs = 3; - else - name_offs = 2; - - name = $(name_offs); - type = $(name_offs + 1); - flags = $(name_offs + 6); - if (name ~ /^\.rodata\./ && type == "PROGBITS") - printf "\t*(%s)\n", name; - } -} +import sys +import re + +def usage(): + print "Usage: {} <section reg exp match> [<skip section>...]".format( \ + sys.argv[0]) + sys.exit (1) + +def main(): + if len(sys.argv) < 2 : + usage() + + in_shdr = False + section_headers = re.compile("Section Headers:") + key_to_flags = re.compile("Key to Flags:") + match_rule = re.compile(sys.argv[1]) + skip_sections = sys.argv[2:] + + for line in sys.stdin: + if section_headers.match(line) : + in_shdr = True; + continue + if key_to_flags.match(line) : + in_shdr = False; + continue + + if not in_shdr : + continue + + words = line.split() + + if len(words) < 3 : + continue + + if words[0] == "[" : + name_offs = 2 + else : + name_offs = 1; + + sect_name = words[name_offs] + sect_type = words[name_offs + 1] + + if sect_type != "PROGBITS" : + continue + + if not match_rule.match(sect_name) : + continue + + if sect_name in skip_sections : + continue + + print '\t*({})'.format(sect_name) + +if __name__ == "__main__": + main() diff --git a/scripts/gen_ld_text_sects.awk b/scripts/gen_ld_text_sects.awk deleted file mode 100644 index 8b25ff79..00000000 --- a/scripts/gen_ld_text_sects.awk +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright (c) 2014, Linaro Limited -# All rights reserved. -# -# Redistribution and use in source and binary forms, with or without -# modification, are permitted provided that the following conditions are met: -# -# 1. Redistributions of source code must retain the above copyright notice, -# this list of conditions and the following disclaimer. -# -# 2. Redistributions in binary form must reproduce the above copyright notice, -# this list of conditions and the following disclaimer in the documentation -# and/or other materials provided with the distribution. -# -# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" -# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE -# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE -# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE -# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR -# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF -# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS -# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN -# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) -# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE -# POSSIBILITY OF SUCH DAMAGE. -# - -BEGIN { - in_shdr = 0; -} - -/Section Headers:/ { - in_shdr = 1; - next; -} - -/Key to Flags:/ { - in_shdr = 0; - next; -} - -{ - if (in_shdr) { - if ($1 == "[") - name_offs = 3; - else - name_offs = 2; - - name = $(name_offs); - type = $(name_offs + 1); - flags = $(name_offs + 6); - if (name ~ /^\.text\./ && type == "PROGBITS") - printf "\t*(%s)\n", name; - } -} |