Skip to contentSkip to conversation

gendwarfksyms: Fix build on 32-bit hosts

PATCH Applied Sami Tolvanen 3 participants 5 messages Nov 17, 2025 – Dec 22, 2025

Subsystems (2)
lore
Share & tools
lore

Sami Tolvanen

author maintainer
#0 lore raw

PATCH 1/1 gendwarfksyms: Fix build on 32-bit hosts

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.

---
 scripts/gendwarfksyms/dwarf.c   | 4 +++-
 scripts/gendwarfksyms/symbols.c | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
scripts/gendwarfksyms/dwarf.c +3 -1
index 3538a7d9cb07..e76d732f5f60 100644
@@ -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);
scripts/gendwarfksyms/symbols.c +3 -2
index ecddcb5ffcdf..42cd27c9cec4 100644
@@ -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

Signature · 1 line
2.52.0.rc1.455.g30608eb744-goog
Tested-by on v1 1/1
#1 lore raw

Hello,

Quoted 11 lines · 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.

---
 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.

Thanks

Michal

Quoted 58 lines
scripts/gendwarfksyms/dwarf.c +3 -1
index 3538a7d9cb07..e76d732f5f60 100644
@@ -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);
scripts/gendwarfksyms/symbols.c +3 -2
index ecddcb5ffcdf..42cd27c9cec4 100644
@@ -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

Signature · 1 line
2.52.0.rc1.455.g30608eb744-goog
author maintainer
#2 lore raw
Quoted 16 lines · Michal Suchánek

Hello,

Quoted 11 lines · 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.

---
 scripts/gendwarfksyms/dwarf.c   | 4 +++-
 scripts/gendwarfksyms/symbols.c | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
Quoted 3 lines

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

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

Sami

#3 lore raw
Quoted 17 lines · Sami Tolvanen
Quoted 16 lines · Michal Suchánek

Hello,

Quoted 11 lines · 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.

---
 scripts/gendwarfksyms/dwarf.c   | 4 +++-
 scripts/gendwarfksyms/symbols.c | 5 +++--
 2 files changed, 6 insertions(+), 3 deletions(-)
Quoted 8 lines
Quoted 3 lines

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

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.

author maintainer Applied
#4 lore raw
In reply to Sami Tolvanen
Quoted 5 lines · 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.

Applied to modules-next, thanks!

[1/1] gendwarfksyms: Fix build on 32-bit hosts

      commit: ddc54f912a551f6eb0bbcfc3880f45fe27a252cb

Best regards,

Sami