mirror of https://github.com/hak5/openwrt.git
linux-5.4: backport modpost upstream patches
Fixes modpost Segmentation Fault with bcm2708 and bcm2709: MODPOST vmlinux.o Segmentation fault make[6]: *** [scripts/Makefile.modpost:66: __modpost] Error 139 Signed-off-by: Álvaro Fernández Rojas <noltari@gmail.com>master
parent
4bde37a2dd
commit
6f9bc70dd5
|
@ -0,0 +1,53 @@
|
|||
From afa0459daa7b08c7b2c879705b69d39b734a11d0 Mon Sep 17 00:00:00 2001
|
||||
From: Masahiro Yamada <yamada.masahiro@socionext.com>
|
||||
Date: Fri, 15 Nov 2019 02:42:21 +0900
|
||||
Subject: [PATCH] modpost: add a helper to get data pointed by a symbol
|
||||
|
||||
When CONFIG_MODULE_REL_CRCS is enabled, the value of __crc_* is not
|
||||
an absolute value, but the address to the CRC data embedded in the
|
||||
.rodata section.
|
||||
|
||||
Getting the data pointed by the symbol value is somewhat complex.
|
||||
Split it out into a new helper, sym_get_data().
|
||||
|
||||
I will reuse it to refactor namespace_from_kstrtabns() in the next
|
||||
commit.
|
||||
|
||||
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
|
||||
---
|
||||
scripts/mod/modpost.c | 17 +++++++++++++----
|
||||
1 file changed, 13 insertions(+), 4 deletions(-)
|
||||
|
||||
--- a/scripts/mod/modpost.c
|
||||
+++ b/scripts/mod/modpost.c
|
||||
@@ -312,6 +312,18 @@ static const char *sec_name(struct elf_i
|
||||
return sech_name(elf, &elf->sechdrs[secindex]);
|
||||
}
|
||||
|
||||
+static void *sym_get_data(const struct elf_info *info, const Elf_Sym *sym)
|
||||
+{
|
||||
+ Elf_Shdr *sechdr = &info->sechdrs[sym->st_shndx];
|
||||
+ unsigned long offset;
|
||||
+
|
||||
+ offset = sym->st_value;
|
||||
+ if (info->hdr->e_type != ET_REL)
|
||||
+ offset -= sechdr->sh_addr;
|
||||
+
|
||||
+ return (void *)info->hdr + sechdr->sh_offset + offset;
|
||||
+}
|
||||
+
|
||||
#define strstarts(str, prefix) (strncmp(str, prefix, strlen(prefix)) == 0)
|
||||
|
||||
static enum export export_from_secname(struct elf_info *elf, unsigned int sec)
|
||||
@@ -701,10 +713,7 @@ static void handle_modversions(struct mo
|
||||
unsigned int *crcp;
|
||||
|
||||
/* symbol points to the CRC in the ELF object */
|
||||
- crcp = (void *)info->hdr + sym->st_value +
|
||||
- info->sechdrs[sym->st_shndx].sh_offset -
|
||||
- (info->hdr->e_type != ET_REL ?
|
||||
- info->sechdrs[sym->st_shndx].sh_addr : 0);
|
||||
+ crcp = sym_get_data(info, sym);
|
||||
crc = TO_NATIVE(*crcp);
|
||||
}
|
||||
sym_update_crc(symname + strlen("__crc_"), mod, crc,
|
|
@ -0,0 +1,62 @@
|
|||
From e84f9fbbece1585f45a03ccc11eeabe121cadc1b Mon Sep 17 00:00:00 2001
|
||||
From: Masahiro Yamada <yamada.masahiro@socionext.com>
|
||||
Date: Fri, 15 Nov 2019 02:42:22 +0900
|
||||
Subject: [PATCH] modpost: refactor namespace_from_kstrtabns() to not hard-code
|
||||
section name
|
||||
|
||||
Currently, namespace_from_kstrtabns() relies on the fact that
|
||||
namespace strings are recorded in the __ksymtab_strings section.
|
||||
Actually, it is coded in include/linux/export.h, but modpost does
|
||||
not need to hard-code the section name.
|
||||
|
||||
Elf_Sym::st_shndx holds the index of the relevant section. Using it is
|
||||
a more portable way to get the namespace string.
|
||||
|
||||
Make namespace_from_kstrtabns() simply call sym_get_data(), and delete
|
||||
the info->ksymtab_strings .
|
||||
|
||||
While I was here, I added more 'const' qualifiers to pointers.
|
||||
|
||||
Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
|
||||
---
|
||||
scripts/mod/modpost.c | 10 +++-------
|
||||
scripts/mod/modpost.h | 1 -
|
||||
2 files changed, 3 insertions(+), 8 deletions(-)
|
||||
|
||||
--- a/scripts/mod/modpost.c
|
||||
+++ b/scripts/mod/modpost.c
|
||||
@@ -360,10 +360,10 @@ static enum export export_from_sec(struc
|
||||
return export_unknown;
|
||||
}
|
||||
|
||||
-static const char *namespace_from_kstrtabns(struct elf_info *info,
|
||||
- Elf_Sym *kstrtabns)
|
||||
+static const char *namespace_from_kstrtabns(const struct elf_info *info,
|
||||
+ const Elf_Sym *sym)
|
||||
{
|
||||
- char *value = info->ksymtab_strings + kstrtabns->st_value;
|
||||
+ const char *value = sym_get_data(info, sym);
|
||||
return value[0] ? value : NULL;
|
||||
}
|
||||
|
||||
@@ -605,10 +605,6 @@ static int parse_elf(struct elf_info *in
|
||||
info->export_unused_gpl_sec = i;
|
||||
else if (strcmp(secname, "__ksymtab_gpl_future") == 0)
|
||||
info->export_gpl_future_sec = i;
|
||||
- else if (strcmp(secname, "__ksymtab_strings") == 0)
|
||||
- info->ksymtab_strings = (void *)hdr +
|
||||
- sechdrs[i].sh_offset -
|
||||
- sechdrs[i].sh_addr;
|
||||
|
||||
if (sechdrs[i].sh_type == SHT_SYMTAB) {
|
||||
unsigned int sh_link_idx;
|
||||
--- a/scripts/mod/modpost.h
|
||||
+++ b/scripts/mod/modpost.h
|
||||
@@ -143,7 +143,6 @@ struct elf_info {
|
||||
Elf_Section export_gpl_sec;
|
||||
Elf_Section export_unused_gpl_sec;
|
||||
Elf_Section export_gpl_future_sec;
|
||||
- char *ksymtab_strings;
|
||||
char *strtab;
|
||||
char *modinfo;
|
||||
unsigned int modinfo_len;
|
|
@ -135,7 +135,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||
|
||||
--- a/scripts/mod/modpost.c
|
||||
+++ b/scripts/mod/modpost.c
|
||||
@@ -2051,7 +2051,9 @@ static void read_symbols(const char *mod
|
||||
@@ -2056,7 +2056,9 @@ static void read_symbols(const char *mod
|
||||
symname = remove_dot(info.strtab + sym->st_name);
|
||||
|
||||
handle_modversions(mod, &info, sym, symname);
|
||||
|
@ -145,7 +145,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||
}
|
||||
|
||||
/* Apply symbol namespaces from __kstrtabns_<symbol> entries. */
|
||||
@@ -2265,8 +2267,10 @@ static void add_header(struct buffer *b,
|
||||
@@ -2270,8 +2272,10 @@ static void add_header(struct buffer *b,
|
||||
buf_printf(b, "\n");
|
||||
buf_printf(b, "BUILD_SALT;\n");
|
||||
buf_printf(b, "\n");
|
||||
|
@ -156,7 +156,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||
buf_printf(b, "\n");
|
||||
buf_printf(b, "__visible struct module __this_module\n");
|
||||
buf_printf(b, "__section(.gnu.linkonce.this_module) = {\n");
|
||||
@@ -2283,8 +2287,10 @@ static void add_header(struct buffer *b,
|
||||
@@ -2288,8 +2292,10 @@ static void add_header(struct buffer *b,
|
||||
|
||||
static void add_intree_flag(struct buffer *b, int is_intree)
|
||||
{
|
||||
|
@ -167,7 +167,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||
}
|
||||
|
||||
/* Cannot check for assembler */
|
||||
@@ -2297,8 +2303,10 @@ static void add_retpoline(struct buffer
|
||||
@@ -2302,8 +2308,10 @@ static void add_retpoline(struct buffer
|
||||
|
||||
static void add_staging_flag(struct buffer *b, const char *name)
|
||||
{
|
||||
|
@ -178,7 +178,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||
}
|
||||
|
||||
/**
|
||||
@@ -2382,11 +2390,13 @@ static void add_depends(struct buffer *b
|
||||
@@ -2387,11 +2395,13 @@ static void add_depends(struct buffer *b
|
||||
|
||||
static void add_srcversion(struct buffer *b, struct module *mod)
|
||||
{
|
||||
|
@ -192,7 +192,7 @@ Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
|||
}
|
||||
|
||||
static void write_if_changed(struct buffer *b, const char *fname)
|
||||
@@ -2656,7 +2666,9 @@ int main(int argc, char **argv)
|
||||
@@ -2661,7 +2671,9 @@ int main(int argc, char **argv)
|
||||
add_staging_flag(&buf, mod->name);
|
||||
err |= add_versions(&buf, mod);
|
||||
add_depends(&buf, mod);
|
||||
|
|
|
@ -8,8 +8,6 @@ Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
|
|||
scripts/mod/file2alias.c | 3 +++
|
||||
1 file changed, 3 insertions(+)
|
||||
|
||||
diff --git a/scripts/mod/file2alias.c b/scripts/mod/file2alias.c
|
||||
index c91eba751804..e756fd80b721 100644
|
||||
--- a/scripts/mod/file2alias.c
|
||||
+++ b/scripts/mod/file2alias.c
|
||||
@@ -38,6 +38,9 @@ typedef struct {
|
||||
|
@ -22,6 +20,3 @@ index c91eba751804..e756fd80b721 100644
|
|||
/* backwards compatibility, don't use in new code */
|
||||
typedef struct {
|
||||
__u8 b[16];
|
||||
--
|
||||
2.21.1 (Apple Git-122.3)
|
||||
|
||||
|
|
Loading…
Reference in New Issue