Skip to contentSkip to conversation

powerpc: fix dedotify for binutils >= 2.26

PATCH Applied Andreas Schwab 3 participants 3 messages Feb 5, 2016 – Feb 9, 2016 PowerPC

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 powerpc: fix dedotify for binutils >= 2.26

Since binutils 2.26 BFD is doing suffix merging on STRTAB sections. But dedotify modifies the symbol names in place, which can also modify unrelated symbols with a name that matches a suffix of a dotted name. To remove the leading dot of a symbol name we can just increment the pointer into the STRTAB section instead.

---
 arch/powerpc/kernel/module_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
arch/powerpc/kernel/module_64.c +1 -1
index ac64ffd..08b7a40 100644
@@ -340,7 +340,7 @@ static void dedotify(Elf64_Sym *syms, unsigned int numsyms, char *strtab)
 			if (name[0] == '.') {
 				if (strcmp(name+1, "TOC.") == 0)
 					syms[i].st_shndx = SHN_ABS;
-				memmove(name, name+1, strlen(name));
+				syms[i].st_name++;
 			}
 		}
 	}
Signature · 7 lines
2.7.0


-- 
Andreas Schwab, [email protected]
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
#1 lore raw
Quoted 6 lines

Since binutils 2.26 BFD is doing suffix merging on STRTAB sections. But dedotify modifies the symbol names in place, which can also modify unrelated symbols with a name that matches a suffix of a dotted name. To remove the leading dot of a symbol name we can just increment the pointer into the STRTAB section instead.

Thanks Andreas.

Quoted 1 line

I think we should get it into stable too.

Anton

Quoted 17 lines
---
 arch/powerpc/kernel/module_64.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/arch/powerpc/kernel/module_64.c index ac64ffd..08b7a40 100644

arch/powerpc/kernel/module_64.c +1 -1
@@ -340,7 +340,7 @@ static void dedotify(Elf64_Sym *syms, unsigned
 int numsyms, char *strtab) if (name[0] == '.') {
 				if (strcmp(name+1, "TOC.") == 0)
 					syms[i].st_shndx = SHN_ABS;
-				memmove(name, name+1, strlen(name));
+				syms[i].st_name++;
 			}
 		}
 	}
reviewer Applied
#2 lore raw
In reply to Andreas Schwab
Quoted 7 lines · Andreas Schwab

Since binutils 2.26 BFD is doing suffix merging on STRTAB sections. But dedotify modifies the symbol names in place, which can also modify unrelated symbols with a name that matches a suffix of a dotted name. To remove the leading dot of a symbol name we can just increment the pointer into the STRTAB section instead.

Applied to powerpc fixes, thanks.

https://git.kernel.org/powerpc/c/f15838e9cac8f78f0cc506529b

cheers