PR26458 UBSAN: elf32-i386.c:3615 left shift of negative value

Happens when poking symbol index -2 into r_info.  (The index is
updated before writing out to file.)

	PR 26458
	* elf/common.h (ELF32_R_INFO): Cast symbol index to unsigned.
This commit is contained in:
Alan Modra
2020-08-26 11:00:22 +09:30
parent 66ad6b4458
commit 1673aff569
2 changed files with 6 additions and 1 deletions

View File

@@ -942,7 +942,7 @@
#define ELF32_R_SYM(i) ((i) >> 8)
#define ELF32_R_TYPE(i) ((i) & 0xff)
#define ELF32_R_INFO(s,t) (((s) << 8) + ((t) & 0xff))
#define ELF32_R_INFO(s,t) (((unsigned) (s) << 8) + ((t) & 0xff))
#define ELF64_R_SYM(i) ((i) >> 32)
#define ELF64_R_TYPE(i) ((i) & 0xffffffff)