linux-modules.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] gendwarfksyms: Fix build on 32-bit hosts
@ 2025-11-17 20:38 Sami Tolvanen
  2025-11-18 16:18 ` Michal Suchánek
  0 siblings, 1 reply; 4+ messages in thread
From: Sami Tolvanen @ 2025-11-17 20:38 UTC (permalink / raw)
  To: linux-modules
  Cc: Luis Chamberlain, Petr Pavlu, Daniel Gomez, linux-kbuild,
	linux-kernel, Michal Suchánek, Sami Tolvanen

We have interchangeably used unsigned long for some of the types
defined in elfutils, assuming they're always 64-bit. This obviously
fails when building gendwarfksyms on 32-bit hosts. Fix the types.

Reported-by: Michal Suchánek <msuchanek@suse.de>
Closes: https://lore.kernel.org/linux-modules/aRcxzPxtJblVSh1y@kitsune.suse.cz/
Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
---
 scripts/gendwarfksyms/dwarf.c   | 4 +++-
 scripts/gendwarfksyms/symbols.c | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c
index 3538a7d9cb07..e76d732f5f60 100644
--- a/scripts/gendwarfksyms/dwarf.c
+++ b/scripts/gendwarfksyms/dwarf.c
@@ -750,6 +750,7 @@ static void process_enumerator_type(struct state *state, struct die *cache,
 				    Dwarf_Die *die)
 {
 	bool overridden = false;
+	unsigned long override;
 	Dwarf_Word value;
 
 	if (stable) {
@@ -761,7 +762,8 @@ static void process_enumerator_type(struct state *state, struct die *cache,
 			return;
 
 		overridden = kabi_get_enumerator_value(
-			state->expand.current_fqn, cache->fqn, &value);
+			state->expand.current_fqn, cache->fqn, &override);
+		value = override;
 	}
 
 	process_list_comma(state, cache);
diff --git a/scripts/gendwarfksyms/symbols.c b/scripts/gendwarfksyms/symbols.c
index ecddcb5ffcdf..42cd27c9cec4 100644
--- a/scripts/gendwarfksyms/symbols.c
+++ b/scripts/gendwarfksyms/symbols.c
@@ -3,6 +3,7 @@
  * Copyright (C) 2024 Google LLC
  */
 
+#include <inttypes.h>
 #include "gendwarfksyms.h"
 
 #define SYMBOL_HASH_BITS 12
@@ -242,7 +243,7 @@ static void elf_for_each_global(int fd, elf_symbol_callback_t func, void *arg)
 				error("elf_getdata failed: %s", elf_errmsg(-1));
 
 			if (shdr->sh_entsize != sym_size)
-				error("expected sh_entsize (%lu) to be %zu",
+				error("expected sh_entsize (%" PRIu64 ") to be %zu",
 				      shdr->sh_entsize, sym_size);
 
 			nsyms = shdr->sh_size / shdr->sh_entsize;
@@ -292,7 +293,7 @@ static void set_symbol_addr(struct symbol *sym, void *arg)
 		hash_add(symbol_addrs, &sym->addr_hash,
 			 symbol_addr_hash(&sym->addr));
 
-		debug("%s -> { %u, %lx }", sym->name, sym->addr.section,
+		debug("%s -> { %u, %" PRIx64 " }", sym->name, sym->addr.section,
 		      sym->addr.address);
 	} else if (sym->addr.section != addr->section ||
 		   sym->addr.address != addr->address) {

base-commit: 6a23ae0a96a600d1d12557add110e0bb6e32730c
-- 
2.52.0.rc1.455.g30608eb744-goog


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] gendwarfksyms: Fix build on 32-bit hosts
  2025-11-17 20:38 [PATCH] gendwarfksyms: Fix build on 32-bit hosts Sami Tolvanen
@ 2025-11-18 16:18 ` Michal Suchánek
  2025-11-25 20:09   ` Sami Tolvanen
  0 siblings, 1 reply; 4+ messages in thread
From: Michal Suchánek @ 2025-11-18 16:18 UTC (permalink / raw)
  To: Sami Tolvanen
  Cc: linux-modules, Luis Chamberlain, Petr Pavlu, Daniel Gomez,
	linux-kbuild, linux-kernel

Hello,

On Mon, Nov 17, 2025 at 08:38:07PM +0000, Sami Tolvanen wrote:
> We have interchangeably used unsigned long for some of the types
> defined in elfutils, assuming they're always 64-bit. This obviously
> fails when building gendwarfksyms on 32-bit hosts. Fix the types.
> 
> Reported-by: Michal Suchánek <msuchanek@suse.de>
> Closes: https://lore.kernel.org/linux-modules/aRcxzPxtJblVSh1y@kitsune.suse.cz/
> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> ---
>  scripts/gendwarfksyms/dwarf.c   | 4 +++-
>  scripts/gendwarfksyms/symbols.c | 5 +++--
>  2 files changed, 6 insertions(+), 3 deletions(-)

with this patch gendwarfksyms builds on 32bit x86 and Arm.

Tested-by: Michal Suchánek <msuchanek@suse.de>

Thanks

Michal

> 
> diff --git a/scripts/gendwarfksyms/dwarf.c b/scripts/gendwarfksyms/dwarf.c
> index 3538a7d9cb07..e76d732f5f60 100644
> --- a/scripts/gendwarfksyms/dwarf.c
> +++ b/scripts/gendwarfksyms/dwarf.c
> @@ -750,6 +750,7 @@ static void process_enumerator_type(struct state *state, struct die *cache,
>  				    Dwarf_Die *die)
>  {
>  	bool overridden = false;
> +	unsigned long override;
>  	Dwarf_Word value;
>  
>  	if (stable) {
> @@ -761,7 +762,8 @@ static void process_enumerator_type(struct state *state, struct die *cache,
>  			return;
>  
>  		overridden = kabi_get_enumerator_value(
> -			state->expand.current_fqn, cache->fqn, &value);
> +			state->expand.current_fqn, cache->fqn, &override);
> +		value = override;
>  	}
>  
>  	process_list_comma(state, cache);
> diff --git a/scripts/gendwarfksyms/symbols.c b/scripts/gendwarfksyms/symbols.c
> index ecddcb5ffcdf..42cd27c9cec4 100644
> --- a/scripts/gendwarfksyms/symbols.c
> +++ b/scripts/gendwarfksyms/symbols.c
> @@ -3,6 +3,7 @@
>   * Copyright (C) 2024 Google LLC
>   */
>  
> +#include <inttypes.h>
>  #include "gendwarfksyms.h"
>  
>  #define SYMBOL_HASH_BITS 12
> @@ -242,7 +243,7 @@ static void elf_for_each_global(int fd, elf_symbol_callback_t func, void *arg)
>  				error("elf_getdata failed: %s", elf_errmsg(-1));
>  
>  			if (shdr->sh_entsize != sym_size)
> -				error("expected sh_entsize (%lu) to be %zu",
> +				error("expected sh_entsize (%" PRIu64 ") to be %zu",
>  				      shdr->sh_entsize, sym_size);
>  
>  			nsyms = shdr->sh_size / shdr->sh_entsize;
> @@ -292,7 +293,7 @@ static void set_symbol_addr(struct symbol *sym, void *arg)
>  		hash_add(symbol_addrs, &sym->addr_hash,
>  			 symbol_addr_hash(&sym->addr));
>  
> -		debug("%s -> { %u, %lx }", sym->name, sym->addr.section,
> +		debug("%s -> { %u, %" PRIx64 " }", sym->name, sym->addr.section,
>  		      sym->addr.address);
>  	} else if (sym->addr.section != addr->section ||
>  		   sym->addr.address != addr->address) {
> 
> base-commit: 6a23ae0a96a600d1d12557add110e0bb6e32730c
> -- 
> 2.52.0.rc1.455.g30608eb744-goog
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gendwarfksyms: Fix build on 32-bit hosts
  2025-11-18 16:18 ` Michal Suchánek
@ 2025-11-25 20:09   ` Sami Tolvanen
  2025-11-26 19:59     ` Daniel Gomez
  0 siblings, 1 reply; 4+ messages in thread
From: Sami Tolvanen @ 2025-11-25 20:09 UTC (permalink / raw)
  To: Michal Suchánek, Daniel Gomez
  Cc: linux-modules, Luis Chamberlain, Petr Pavlu, linux-kbuild,
	linux-kernel

On Tue, Nov 18, 2025 at 8:18 AM Michal Suchánek <msuchanek@suse.de> wrote:
>
> Hello,
>
> On Mon, Nov 17, 2025 at 08:38:07PM +0000, Sami Tolvanen wrote:
> > We have interchangeably used unsigned long for some of the types
> > defined in elfutils, assuming they're always 64-bit. This obviously
> > fails when building gendwarfksyms on 32-bit hosts. Fix the types.
> >
> > Reported-by: Michal Suchánek <msuchanek@suse.de>
> > Closes: https://lore.kernel.org/linux-modules/aRcxzPxtJblVSh1y@kitsune.suse.cz/
> > Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
> > ---
> >  scripts/gendwarfksyms/dwarf.c   | 4 +++-
> >  scripts/gendwarfksyms/symbols.c | 5 +++--
> >  2 files changed, 6 insertions(+), 3 deletions(-)
>
> with this patch gendwarfksyms builds on 32bit x86 and Arm.
>
> Tested-by: Michal Suchánek <msuchanek@suse.de>

Great, thanks for testing!  Daniel, do you want to take this fix
through the modules tree?

Sami

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] gendwarfksyms: Fix build on 32-bit hosts
  2025-11-25 20:09   ` Sami Tolvanen
@ 2025-11-26 19:59     ` Daniel Gomez
  0 siblings, 0 replies; 4+ messages in thread
From: Daniel Gomez @ 2025-11-26 19:59 UTC (permalink / raw)
  To: Sami Tolvanen, Michal Suchánek
  Cc: linux-modules, Luis Chamberlain, Petr Pavlu, linux-kbuild,
	linux-kernel



On 25/11/2025 21.09, Sami Tolvanen wrote:
> On Tue, Nov 18, 2025 at 8:18 AM Michal Suchánek <msuchanek@suse.de> wrote:
>>
>> Hello,
>>
>> On Mon, Nov 17, 2025 at 08:38:07PM +0000, Sami Tolvanen wrote:
>>> We have interchangeably used unsigned long for some of the types
>>> defined in elfutils, assuming they're always 64-bit. This obviously
>>> fails when building gendwarfksyms on 32-bit hosts. Fix the types.
>>>
>>> Reported-by: Michal Suchánek <msuchanek@suse.de>
>>> Closes: https://lore.kernel.org/linux-modules/aRcxzPxtJblVSh1y@kitsune.suse.cz/
>>> Signed-off-by: Sami Tolvanen <samitolvanen@google.com>
>>> ---
>>>  scripts/gendwarfksyms/dwarf.c   | 4 +++-
>>>  scripts/gendwarfksyms/symbols.c | 5 +++--
>>>  2 files changed, 6 insertions(+), 3 deletions(-)
>>
>> with this patch gendwarfksyms builds on 32bit x86 and Arm.
>>
>> Tested-by: Michal Suchánek <msuchanek@suse.de>
> 
> Great, thanks for testing!  Daniel, do you want to take this fix
> through the modules tree?
> 
> Sami

Absolutely! Since we are at the end of the rc cycle, I'll merge this after
sending the current queued patches.

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2025-11-26 19:59 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-17 20:38 [PATCH] gendwarfksyms: Fix build on 32-bit hosts Sami Tolvanen
2025-11-18 16:18 ` Michal Suchánek
2025-11-25 20:09   ` Sami Tolvanen
2025-11-26 19:59     ` Daniel Gomez

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).