proc: support position independent executables (PIE)

Support for position independent executables (PIE) on the native linux
backend, the gdbserver backend on linux and the core backend.
Also implemented in the windows native backend, but it can't be tested
because go doesn't support PIE on windows yet.
This commit is contained in:
aarzilli
2018-05-29 17:01:51 +02:00
committed by Derek Parker
parent 4e4ed02948
commit 74c98bc961
41 changed files with 467 additions and 161 deletions

View File

@ -193,7 +193,7 @@ func (err *IsNilErr) Error() string {
}
func globalScope(bi *BinaryInfo, mem MemoryReadWriter) *EvalScope {
return &EvalScope{Location: Location{}, Regs: op.DwarfRegisters{}, Mem: mem, Gvar: nil, BinInfo: bi, frameOffset: 0}
return &EvalScope{Location: Location{}, Regs: op.DwarfRegisters{StaticBase: bi.staticBase}, Mem: mem, Gvar: nil, BinInfo: bi, frameOffset: 0}
}
func (scope *EvalScope) newVariable(name string, addr uintptr, dwarfType godwarf.Type, mem MemoryReadWriter) *Variable {
@ -319,9 +319,12 @@ func newVariable(name string, addr uintptr, dwarfType godwarf.Type, bi *BinaryIn
func resolveTypedef(typ godwarf.Type) godwarf.Type {
for {
if tt, ok := typ.(*godwarf.TypedefType); ok {
switch tt := typ.(type) {
case *godwarf.TypedefType:
typ = tt.Type
} else {
case *godwarf.QualType:
typ = tt.Type
default:
return typ
}
}
@ -2046,7 +2049,7 @@ func (scope *EvalScope) Locals() ([]*Variable, error) {
var vars []*Variable
var depths []int
varReader := reader.Variables(scope.BinInfo.dwarf, scope.Fn.offset, scope.PC, scope.Line, true)
varReader := reader.Variables(scope.BinInfo.dwarf, scope.Fn.offset, reader.ToRelAddr(scope.PC, scope.BinInfo.staticBase), scope.Line, true)
hasScopes := false
for varReader.Next() {
entry := varReader.Entry()