forked from torvalds/linux
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
x86/vdso: Hack to keep 64-bit Go programs working
The Go runtime has a buggy vDSO parser that currently segfaults. This writes an empty SHT_DYNSYM entry that causes Go's runtime to malfunction by thinking that the vDSO is empty rather than malfunctioning by running off the end and segfaulting. This affects x86-64 only as far as we know, so we do not need this for the i386 and x32 vdsos. Signed-off-by: Andy Lutomirski <[email protected]> Link: http://lkml.kernel.org/r/d10618176c4bd39b457a5e85c497295c90cab1bc.1402620737.git.luto@amacapital.net Signed-off-by: H. Peter Anvin <[email protected]>
- Loading branch information
Showing
3 changed files
with
60 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* | ||
* Copyright 2014 Andy Lutomirski | ||
* Subject to the GNU Public License, v.2 | ||
* | ||
* Hack to keep broken Go programs working. | ||
* | ||
* The Go runtime had a couple of bugs: it would read the section table to try | ||
* to figure out how many dynamic symbols there were (it shouldn't have looked | ||
* at the section table at all) and, if there were no SHT_SYNDYM section table | ||
* entry, it would use an uninitialized value for the number of symbols. As a | ||
* workaround, we supply a minimal section table. vdso2c will adjust the | ||
* in-memory image so that "vdso_fake_sections" becomes the section table. | ||
* | ||
* The bug was introduced by: | ||
* https://code.google.com/p/go/source/detail?r=56ea40aac72b (2012-08-31) | ||
* and is being addressed in the Go runtime in this issue: | ||
* https://code.google.com/p/go/issues/detail?id=8197 | ||
*/ | ||
|
||
#ifndef __x86_64__ | ||
#error This hack is specific to the 64-bit vDSO | ||
#endif | ||
|
||
#include <linux/elf.h> | ||
|
||
extern const __visible struct elf64_shdr vdso_fake_sections[]; | ||
const __visible struct elf64_shdr vdso_fake_sections[] = { | ||
{ | ||
.sh_type = SHT_DYNSYM, | ||
.sh_entsize = sizeof(Elf64_Sym), | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters