Skip to contentSkip to conversation

ELF, uapi: fixup ELF_ST_TYPE definition

PATCH Applied Alexey Dobriyan 2 participants 3 messages Apr 29, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ELF, uapi: fixup ELF_ST_TYPE definition

This is very theoretical compile failure:

ELF_ST_TYPE(st_info = A)

Cast will bind first and st_info will stop being lvalue:

error: lvalue required as left operand of assignment

Given that the only use of this macro is

	ELF_ST_TYPE(sym->st_info)

where st_info is "unsigned char" I've decided to remove cast especially given that companion macro ELF_ST_BIND doesn't use cast.

---

 include/uapi/linux/elf.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
include/uapi/linux/elf.h +1 -1
@@ -134,7 +134,7 @@ typedef __s64	Elf64_Sxword;
 #define STT_TLS     6
 
 #define ELF_ST_BIND(x)		((x) >> 4)
-#define ELF_ST_TYPE(x)		(((unsigned int) x) & 0xf)
+#define ELF_ST_TYPE(x)		((x) & 0xf)
 #define ELF32_ST_BIND(x)	ELF_ST_BIND(x)
 #define ELF32_ST_TYPE(x)	ELF_ST_TYPE(x)
 #define ELF64_ST_BIND(x)	ELF_ST_BIND(x)
Acked-by on v1 1/1
#1 lore raw
Quoted 12 lines · Alexey Dobriyan

This is very theoretical compile failure:

ELF_ST_TYPE(st_info = A)

Cast will bind first and st_info will stop being lvalue:

error: lvalue required as left operand of assignment

Given that the only use of this macro is

	ELF_ST_TYPE(sym->st_info)
Quoted 8 lines

where st_info is "unsigned char" I've decided to remove cast especially given that companion macro ELF_ST_BIND doesn't use cast.

---

 include/uapi/linux/elf.h |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

It looks like akpm already pulled this, so:

Please keep Eric & I CCed on ELF changes; there's a MAINTAINERS entry now...

-Kees

Signature · 1 line
Kees Cook
#2 lore raw
Quoted 2 lines · Kees Cook

Please keep Eric & I CCed on ELF changes; there's a MAINTAINERS entry now...

Hah!

I honestly searched for 'ELF' before sending and didn't find anything.