modpost: move some defines to the file head
PATCH 1/1 modpost: move some defines to the file head
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function)
return !is_mapping_symbol(name, elf->hdr->e_machine == EM_RISCV);
Fix it by moving the EM_RISCV to the file head, also some other defines in case of similar problem in the future.
--- scripts/mod/modpost.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
scripts/mod/modpost.c +16 -16
@@ -60,6 +60,22 @@ static unsigned int nr_unresolved;#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) +#ifndef EM_RISCV +#define EM_RISCV 243 +#endif + +#ifndef R_RISCV_SUB32 +#define R_RISCV_SUB32 39 +#endif + +#ifndef EM_LOONGARCH +#define EM_LOONGARCH 258 +#endif + +#ifndef R_LARCH_SUB32 +#define R_LARCH_SUB32 55 +#endif +void __attribute__((format (printf,2 ,3 )))modpost_log (enum loglevel loglevel,const char *fmt, ...) {
@@ -1428,22 +1444,6 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)return 0 ; } -#ifndef EM_RISCV -#define EM_RISCV 243 -#endif - -#ifndef R_RISCV_SUB32 -#define R_RISCV_SUB32 39 -#endif - -#ifndef EM_LOONGARCH -#define EM_LOONGARCH 258 -#endif - -#ifndef R_LARCH_SUB32 -#define R_LARCH_SUB32 55 -#endif -static void section_rela (struct module *mod,struct elf_info *elf,Elf_Shdr *sechdr) {
Signature · 1 line
2.41.0
+To: Luis Chamberlain, the commiter of the breakage
Quoted 9 lines · Kefeng Wang
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function)
return !is_mapping_symbol(name,elf->hdr->e_machine==EM_RISCV);Fix it by moving the
EM_RISCVto the file head, also some other defines in case of similar problem in the future.
BTW, why is the flag 'is_riscv' needed?
All symbols starting with '$' look special to me.
Why not like this?
if (str[0] == '$')
return true;
return false;Quoted 57 lines
Signed-off-by Kefeng Wang <[email protected]>--- scripts/mod/modpost.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)scripts/mod/modpost.c +16
-17@@ -60,6 +60,22 @@ static unsigned int nr_unresolved;#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) +#ifndef EM_RISCV +#define EM_RISCV 243 +#endif + +#ifndef R_RISCV_SUB32 +#define R_RISCV_SUB32 39 +#endif + +#ifndef EM_LOONGARCH +#define EM_LOONGARCH 258 +#endif + +#ifndef R_LARCH_SUB32 +#define R_LARCH_SUB32 55 +#endif +void __attribute__((format (printf,2 ,3 )))modpost_log (enum loglevel loglevel,const char *fmt, ...) {@@ -1428,22 +1444,6 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)return 0 ; } -#ifndef EM_RISCV -#define EM_RISCV 243 -#endif - -#ifndef R_RISCV_SUB32 -#define R_RISCV_SUB32 39 -#endif - -#ifndef EM_LOONGARCH -#define EM_LOONGARCH 258 -#endif - -#ifndef R_LARCH_SUB32 -#define R_LARCH_SUB32 55 -#endif -static void section_rela (struct module *mod,struct elf_info *elf,Elf_Shdr *sechdr) { --
Quoted 2 lines
2.41.0
--
Best Regards
Masahiro Yamada
Quoted 24 lines · On Wed, 12 Jul 2023 08:55:23 PDT (-0700), [email protected] wrote:
+To: Luis Chamberlain, the commiter of the breakage
Quoted 9 lines · Kefeng Wang
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function)
return !is_mapping_symbol(name,elf->hdr->e_machine==EM_RISCV);Fix it by moving the
EM_RISCVto the file head, also some other defines in case of similar problem in the future.BTW, why is the flag '
is_riscv' needed?All symbols starting with '$' look special to me.
Quoted 7 lines
Why not like this?
if (str[0] == '$') return true; return false;
There's a bit of commentary in the v1 <https://lore.kernel.org/all/[email protected]/>, but essentially it's not necessary. I just wanted to play things safe and avoid changing the mapping symbol detection elsewhere in order to deal with RISC-V.
IIRC we decided $ was special in RISC-V because there were some other ports that behaved that way, but it wasn't universal. If folks are OK treating $-prefixed symbols as special everywhere that's fine with me, I just wasn't sure what the right answer was.
There's also some similar arch-specific-ness with the labels and such in here.
Quoted 58 lines
Quoted 58 lines
Signed-off-by Kefeng Wang <[email protected]>--- scripts/mod/modpost.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)scripts/mod/modpost.c +16
-17@@ -60,6 +60,22 @@ static unsigned int nr_unresolved;#define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) +#ifndef EM_RISCV +#define EM_RISCV 243 +#endif + +#ifndef R_RISCV_SUB32 +#define R_RISCV_SUB32 39 +#endif + +#ifndef EM_LOONGARCH +#define EM_LOONGARCH 258 +#endif + +#ifndef R_LARCH_SUB32 +#define R_LARCH_SUB32 55 +#endif +void __attribute__((format (printf,2 ,3 )))modpost_log (enum loglevel loglevel,const char *fmt, ...) {@@ -1428,22 +1444,6 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r)return 0 ; } -#ifndef EM_RISCV -#define EM_RISCV 243 -#endif - -#ifndef R_RISCV_SUB32 -#define R_RISCV_SUB32 39 -#endif - -#ifndef EM_LOONGARCH -#define EM_LOONGARCH 258 -#endif - -#ifndef R_LARCH_SUB32 -#define R_LARCH_SUB32 55 -#endif -static void section_rela (struct module *mod,struct elf_info *elf,Elf_Shdr *sechdr) { --2.41.0
Hi, kindly ping, the build issue still exist in Linux-next.
Quoted 97 lines · Palmer Dabbelt
Quoted 24 lines · On Wed, 12 Jul 2023 08:55:23 PDT (-0700), [email protected] wrote:
+To: Luis Chamberlain, the commiter of the breakage
Quoted 9 lines · Kefeng Wang
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function) return !is_mapping_symbol(name,elf->hdr->e_machine==EM_RISCV);Fix it by moving the
EM_RISCVto the file head, also some other defines in case of similar problem in the future.BTW, why is the flag '
is_riscv' needed?All symbols starting with '$' look special to me.
Quoted 7 lines
Why not like this?
if (str[0] == '$')
return true;return false;
There's a bit of commentary in the v1 <https://lore.kernel.org/all/[email protected]/>, but essentially it's not necessary. I just wanted to play things safe and avoid changing the mapping symbol detection elsewhere in order to deal with RISC-V.
IIRC we decided $ was special in RISC-V because there were some other ports that behaved that way, but it wasn't universal. If folks are OK treating $-prefixed symbols as special everywhere that's fine with me, I just wasn't sure what the right answer was. There's also some similar arch-specific-ness with the labels and such in here.
Quoted 59 lines
Quoted 59 lines
Signed-off-by Kefeng Wang <[email protected]>---
scripts/mod/modpost.c | 32 ++++++++++++++++----------------1 file changed, 16 insertions(+), 16 deletions(-)scripts/mod/modpost.c +16
-16@@ -60,6 +60,22 @@ static unsigned int nr_unresolved; #define MODULE_NAME_LEN (64 - sizeof(Elf_Addr)) +#ifndef EM_RISCV +#define EM_RISCV 243 +#endif + +#ifndef R_RISCV_SUB32 +#define R_RISCV_SUB32 39 +#endif + +#ifndef EM_LOONGARCH +#define EM_LOONGARCH 258 +#endif + +#ifndef R_LARCH_SUB32 +#define R_LARCH_SUB32 55 +#endif + void __attribute__((format(printf, 2, 3))) modpost_log(enum loglevel loglevel, const char *fmt, ...) {@@ -1428,22 +1444,6 @@ static int addend_mips_rel(uint32_t *location, Elf_Rela *r) return 0; } -#ifndef EM_RISCV -#define EM_RISCV 243 -#endif - -#ifndef R_RISCV_SUB32 -#define R_RISCV_SUB32 39 -#endif - -#ifndef EM_LOONGARCH -#define EM_LOONGARCH 258 -#endif - -#ifndef R_LARCH_SUB32 -#define R_LARCH_SUB32 55 -#endif - static void section_rela(struct module *mod, struct elf_info *elf, Elf_Shdr *sechdr){
Signature · 1 line
2.41.0
Quoted 40 lines · Palmer Dabbelt
Quoted 24 lines · On Wed, 12 Jul 2023 08:55:23 PDT (-0700), [email protected] wrote:
+To: Luis Chamberlain, the commiter of the breakage
Quoted 9 lines · Kefeng Wang
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function)
return !is_mapping_symbol(name,elf->hdr->e_machine==EM_RISCV);Fix it by moving the
EM_RISCVto the file head, also some other defines in case of similar problem in the future.BTW, why is the flag '
is_riscv' needed?All symbols starting with '$' look special to me.
Quoted 7 lines
Why not like this?
if (str[0] == '$') return true; return false;There's a bit of commentary in the v1
<https://lore.kernel.org/all/[email protected]/>,
but essentially it's not necessary. I just wanted to play things safe and avoid changing the mapping symbol detection elsewhere in order to deal with RISC-V.
Quoted 7 lines
IIRC we decided $ was special in RISC-V because there were some other ports that behaved that way, but it wasn't universal. If folks are OK treating $-prefixed symbols as special everywhere that's fine with me, I just wasn't sure what the right answer was.
There's also some similar arch-specific-ness with the labels and such in here.
Hi Palmer,
I am not a toolchain expert, but my gut feeling is that the code was safer than needed.
I'd like to remove the 'is_riscv' switch rather than applying this patch.
Will you send a patch, or do you want me to do so?
--
Best Regards
Masahiro Yamada
Quoted 51 lines · On Fri, 21 Jul 2023 04:58:20 PDT (-0700), [email protected] wrote:
Quoted 40 lines · Palmer Dabbelt
Quoted 24 lines · On Wed, 12 Jul 2023 08:55:23 PDT (-0700), [email protected] wrote:
+To: Luis Chamberlain, the commiter of the breakage
Quoted 9 lines · Kefeng Wang
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function)
return !is_mapping_symbol(name,elf->hdr->e_machine==EM_RISCV);Fix it by moving the
EM_RISCVto the file head, also some other defines in case of similar problem in the future.BTW, why is the flag '
is_riscv' needed?All symbols starting with '$' look special to me.
Quoted 7 lines
Why not like this?
if (str[0] == '$') return true; return false;There's a bit of commentary in the v1
<https://lore.kernel.org/all/[email protected]/>,
but essentially it's not necessary. I just wanted to play things safe and avoid changing the mapping symbol detection elsewhere in order to deal with RISC-V.Quoted 7 lines
IIRC we decided $ was special in RISC-V because there were some other ports that behaved that way, but it wasn't universal. If folks are OK treating $-prefixed symbols as special everywhere that's fine with me, I just wasn't sure what the right answer was.
There's also some similar arch-specific-ness with the labels and such in here.
Hi Palmer,
Quoted 8 lines
I am not a toolchain expert, but my gut feeling is that the code was safer than needed.
I'd like to remove the '
is_riscv' switch rather than applying this patch.Will you send a patch, or do you want me to do so?
I've pretty much got it already. Do you want it on top of the original patch, or just squashed in so you can drop it?
Quoted 57 lines · Palmer Dabbelt
Quoted 55 lines · On Fri, 21 Jul 2023 04:58:20 PDT (-0700), [email protected] wrote:
Quoted 40 lines · Palmer Dabbelt
Quoted 24 lines · On Wed, 12 Jul 2023 08:55:23 PDT (-0700), [email protected] wrote:
+To: Luis Chamberlain, the commiter of the breakage
Quoted 9 lines · Kefeng Wang
with "module: Ignore RISC-V mapping symbols too", build error occurs,
scripts/mod/modpost.c: In function ‘is_valid_name’:scripts/mod/modpost.c:1055:57: error: ‘EM_RISCV’ undeclared (first use in this function)
return !is_mapping_symbol(name,elf->hdr->e_machine==EM_RISCV);Fix it by moving the
EM_RISCVto the file head, also some other defines in case of similar problem in the future.BTW, why is the flag '
is_riscv' needed?All symbols starting with '$' look special to me.
Quoted 7 lines
Why not like this?
if (str[0] == '$') return true; return false;There's a bit of commentary in the v1
<https://lore.kernel.org/all/[email protected]/>,
but essentially it's not necessary. I just wanted to play things safe and avoid changing the mapping symbol detection elsewhere in order to deal with RISC-V.Quoted 7 lines
IIRC we decided $ was special in RISC-V because there were some other ports that behaved that way, but it wasn't universal. If folks are OK treating $-prefixed symbols as special everywhere that's fine with me, I just wasn't sure what the right answer was.
There's also some similar arch-specific-ness with the labels and such in here.
Hi Palmer,
I am not a toolchain expert, but my gut feeling is that the code was safer than needed.
Quoted 7 lines
Quoted 4 lines
I'd like to remove the '
is_riscv' switch rather than applying this patch.Will you send a patch, or do you want me to do so?
I've pretty much got it already. Do you want it on top of the original patch, or just squashed in so you can drop it?
It is up to Luis Chamberlain.
The original patch does not exist in my kbuild tree. (and I was not even not CC'ed, so I had not noticed it before I saw this report)
commit c05780ef3c190c2dafbf0be8e65d4f01103ad577
Author: Palmer Dabbelt <[email protected]> AuthorDate: Fri Jul 7 09:00:51 2023 -0700 Commit: Luis Chamberlain <[email protected]> CommitDate: Mon Jul 10 12:45:23 2023 -0700
module: Ignore RISC-V mapping symbols too
RISC-V has an extended form of mapping symbols that we use to encode the ISA when it changes in the middle of an ELF. This trips up modpost as a build failure, I haven't yet verified it yet but I believe the kallsyms difference should result in stacks looking sane again.
--
Best Regards
Masahiro Yamada