aboutsummaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rw-r--r--scripts/Kbuild.include9
-rw-r--r--scripts/Makefile.build2
-rw-r--r--scripts/gcc-ld29
-rw-r--r--scripts/gen_initramfs_list.sh2
-rwxr-xr-xscripts/ld-version.sh8
-rw-r--r--scripts/mod/modpost.c38
-rw-r--r--scripts/mod/modpost.h2
7 files changed, 85 insertions, 5 deletions
diff --git a/scripts/Kbuild.include b/scripts/Kbuild.include
index 547e15daf03d..93a0da26582b 100644
--- a/scripts/Kbuild.include
+++ b/scripts/Kbuild.include
@@ -155,6 +155,15 @@ ld-option = $(call try-run,\
155# Important: no spaces around options 155# Important: no spaces around options
156ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2)) 156ar-option = $(call try-run, $(AR) rc$(1) "$$TMP",$(1),$(2))
157 157
158# ld-version
159# Usage: $(call ld-version)
160# Note this is mainly for HJ Lu's 3 number binutil versions
161ld-version = $(shell $(LD) --version | $(srctree)/scripts/ld-version.sh)
162
163# ld-ifversion
164# Usage: $(call ld-ifversion, -ge, 22252, y)
165ld-ifversion = $(shell [ $(call ld-version) $(1) $(2) ] && echo $(3))
166
158###### 167######
159 168
160### 169###
diff --git a/scripts/Makefile.build b/scripts/Makefile.build
index d5d859c80729..9f0ee22b914f 100644
--- a/scripts/Makefile.build
+++ b/scripts/Makefile.build
@@ -198,7 +198,7 @@ $(multi-objs-y:.o=.s) : modname = $(modname-multi)
198$(multi-objs-y:.o=.lst) : modname = $(modname-multi) 198$(multi-objs-y:.o=.lst) : modname = $(modname-multi)
199 199
200quiet_cmd_cc_s_c = CC $(quiet_modtag) $@ 200quiet_cmd_cc_s_c = CC $(quiet_modtag) $@
201cmd_cc_s_c = $(CC) $(c_flags) -fverbose-asm -S -o $@ $< 201cmd_cc_s_c = $(CC) $(c_flags) $(DISABLE_LTO) -fverbose-asm -S -o $@ $<
202 202
203$(obj)/%.s: $(src)/%.c FORCE 203$(obj)/%.s: $(src)/%.c FORCE
204 $(call if_changed_dep,cc_s_c) 204 $(call if_changed_dep,cc_s_c)
diff --git a/scripts/gcc-ld b/scripts/gcc-ld
new file mode 100644
index 000000000000..cadab9a13ed7
--- /dev/null
+++ b/scripts/gcc-ld
@@ -0,0 +1,29 @@
1#!/bin/sh
2# run gcc with ld options
3# used as a wrapper to execute link time optimizations
4# yes virginia, this is not pretty
5
6ARGS="-nostdlib"
7
8while [ "$1" != "" ] ; do
9 case "$1" in
10 -save-temps|-m32|-m64) N="$1" ;;
11 -r) N="$1" ;;
12 -[Wg]*) N="$1" ;;
13 -[olv]|-[Ofd]*|-nostdlib) N="$1" ;;
14 --end-group|--start-group)
15 N="-Wl,$1" ;;
16 -[RTFGhIezcbyYu]*|\
17--script|--defsym|-init|-Map|--oformat|-rpath|\
18-rpath-link|--sort-section|--section-start|-Tbss|-Tdata|-Ttext|\
19--version-script|--dynamic-list|--version-exports-symbol|--wrap|-m)
20 A="$1" ; shift ; N="-Wl,$A,$1" ;;
21 -[m]*) N="$1" ;;
22 -*) N="-Wl,$1" ;;
23 *) N="$1" ;;
24 esac
25 ARGS="$ARGS $N"
26 shift
27done
28
29exec $CC $ARGS
diff --git a/scripts/gen_initramfs_list.sh b/scripts/gen_initramfs_list.sh
index ef474098d9f1..17fa901418ae 100644
--- a/scripts/gen_initramfs_list.sh
+++ b/scripts/gen_initramfs_list.sh
@@ -257,7 +257,7 @@ case "$arg" in
257 && compr="lzop -9 -f" 257 && compr="lzop -9 -f"
258 echo "$output_file" | grep -q "\.lz4$" \ 258 echo "$output_file" | grep -q "\.lz4$" \
259 && [ -x "`which lz4 2> /dev/null`" ] \ 259 && [ -x "`which lz4 2> /dev/null`" ] \
260 && compr="lz4 -9 -f" 260 && compr="lz4 -l -9 -f"
261 echo "$output_file" | grep -q "\.cpio$" && compr="cat" 261 echo "$output_file" | grep -q "\.cpio$" && compr="cat"
262 shift 262 shift
263 ;; 263 ;;
diff --git a/scripts/ld-version.sh b/scripts/ld-version.sh
new file mode 100755
index 000000000000..198580d245e0
--- /dev/null
+++ b/scripts/ld-version.sh
@@ -0,0 +1,8 @@
1#!/usr/bin/awk -f
2# extract linker version number from stdin and turn into single number
3 {
4 gsub(".*)", "");
5 split($1,a, ".");
6 print a[1]*10000000 + a[2]*100000 + a[3]*10000 + a[4]*100 + a[5];
7 exit
8 }
diff --git a/scripts/mod/modpost.c b/scripts/mod/modpost.c
index 40610984a1b5..066355673930 100644
--- a/scripts/mod/modpost.c
+++ b/scripts/mod/modpost.c
@@ -623,7 +623,10 @@ static void handle_modversions(struct module *mod, struct elf_info *info,
623 623
624 switch (sym->st_shndx) { 624 switch (sym->st_shndx) {
625 case SHN_COMMON: 625 case SHN_COMMON:
626 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name); 626 if (!strncmp(symname, "__gnu_lto_", sizeof("__gnu_lto_")-1)) {
627 /* Should warn here, but modpost runs before the linker */
628 } else
629 warn("\"%s\" [%s] is COMMON symbol\n", symname, mod->name);
627 break; 630 break;
628 case SHN_UNDEF: 631 case SHN_UNDEF:
629 /* undefined symbol */ 632 /* undefined symbol */
@@ -849,6 +852,7 @@ static const char *section_white_list[] =
849 ".xt.lit", /* xtensa */ 852 ".xt.lit", /* xtensa */
850 ".arcextmap*", /* arc */ 853 ".arcextmap*", /* arc */
851 ".gnu.linkonce.arcext*", /* arc : modules */ 854 ".gnu.linkonce.arcext*", /* arc : modules */
855 ".gnu.lto*",
852 NULL 856 NULL
853}; 857};
854 858
@@ -1455,6 +1459,10 @@ static void check_section_mismatch(const char *modname, struct elf_info *elf,
1455 to = find_elf_symbol(elf, r->r_addend, sym); 1459 to = find_elf_symbol(elf, r->r_addend, sym);
1456 tosym = sym_name(elf, to); 1460 tosym = sym_name(elf, to);
1457 1461
1462 if (!strncmp(fromsym, "reference___initcall",
1463 sizeof("reference___initcall")-1))
1464 return;
1465
1458 /* check whitelist - we may ignore it */ 1466 /* check whitelist - we may ignore it */
1459 if (secref_whitelist(mismatch, 1467 if (secref_whitelist(mismatch,
1460 fromsec, fromsym, tosec, tosym)) { 1468 fromsec, fromsym, tosec, tosym)) {
@@ -1502,6 +1510,16 @@ static int addend_386_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
1502#define R_ARM_JUMP24 29 1510#define R_ARM_JUMP24 29
1503#endif 1511#endif
1504 1512
1513#ifndef R_ARM_THM_CALL
1514#define R_ARM_THM_CALL 10
1515#endif
1516#ifndef R_ARM_THM_JUMP24
1517#define R_ARM_THM_JUMP24 30
1518#endif
1519#ifndef R_ARM_THM_JUMP19
1520#define R_ARM_THM_JUMP19 51
1521#endif
1522
1505static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r) 1523static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
1506{ 1524{
1507 unsigned int r_typ = ELF_R_TYPE(r->r_info); 1525 unsigned int r_typ = ELF_R_TYPE(r->r_info);
@@ -1515,6 +1533,9 @@ static int addend_arm_rel(struct elf_info *elf, Elf_Shdr *sechdr, Elf_Rela *r)
1515 case R_ARM_PC24: 1533 case R_ARM_PC24:
1516 case R_ARM_CALL: 1534 case R_ARM_CALL:
1517 case R_ARM_JUMP24: 1535 case R_ARM_JUMP24:
1536 case R_ARM_THM_CALL:
1537 case R_ARM_THM_JUMP24:
1538 case R_ARM_THM_JUMP19:
1518 /* From ARM ABI: ((S + A) | T) - P */ 1539 /* From ARM ABI: ((S + A) | T) - P */
1519 r->r_addend = (int)(long)(elf->hdr + 1540 r->r_addend = (int)(long)(elf->hdr +
1520 sechdr->sh_offset + 1541 sechdr->sh_offset +
@@ -1680,6 +1701,19 @@ static void check_sec_ref(struct module *mod, const char *modname,
1680 } 1701 }
1681} 1702}
1682 1703
1704static char *remove_dot(char *s)
1705{
1706 char *end;
1707 int n = strcspn(s, ".");
1708
1709 if (n > 0 && s[n] != 0) {
1710 strtoul(s + n + 1, &end, 10);
1711 if (end > s + n + 1 && (*end == '.' || *end == 0))
1712 s[n] = 0;
1713 }
1714 return s;
1715}
1716
1683static void read_symbols(char *modname) 1717static void read_symbols(char *modname)
1684{ 1718{
1685 const char *symname; 1719 const char *symname;
@@ -1718,7 +1752,7 @@ static void read_symbols(char *modname)
1718 } 1752 }
1719 1753
1720 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) { 1754 for (sym = info.symtab_start; sym < info.symtab_stop; sym++) {
1721 symname = info.strtab + sym->st_name; 1755 symname = remove_dot(info.strtab + sym->st_name);
1722 1756
1723 handle_modversions(mod, &info, sym, symname); 1757 handle_modversions(mod, &info, sym, symname);
1724 handle_moddevtable(mod, &info, sym, symname); 1758 handle_moddevtable(mod, &info, sym, symname);
diff --git a/scripts/mod/modpost.h b/scripts/mod/modpost.h
index 51207e4d5f8b..168b43dc0a59 100644
--- a/scripts/mod/modpost.h
+++ b/scripts/mod/modpost.h
@@ -127,7 +127,7 @@ struct elf_info {
127 Elf_Section export_gpl_sec; 127 Elf_Section export_gpl_sec;
128 Elf_Section export_unused_gpl_sec; 128 Elf_Section export_unused_gpl_sec;
129 Elf_Section export_gpl_future_sec; 129 Elf_Section export_gpl_future_sec;
130 const char *strtab; 130 char *strtab;
131 char *modinfo; 131 char *modinfo;
132 unsigned int modinfo_len; 132 unsigned int modinfo_len;
133 133