compiler: emit non-PIE executables
This fixes a problem on baremetal targets, where PIE doesn't make any sense. Specifically, on ARM, the compiler sometimes inserted GOT pointers for linker-defined globals.
Этот коммит содержится в:
родитель
3e6750ae23
коммит
2496ae9967
2 изменённых файлов: 6 добавлений и 5 удалений
|
@ -93,7 +93,7 @@ func NewCompiler(pkgName, triple string, dumpSSA bool) (*Compiler, error) {
|
|||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
c.machine = target.CreateTargetMachine(triple, "", "", llvm.CodeGenLevelDefault, llvm.RelocPIC, llvm.CodeModelDefault)
|
||||
c.machine = target.CreateTargetMachine(triple, "", "", llvm.CodeGenLevelDefault, llvm.RelocStatic, llvm.CodeModelDefault)
|
||||
c.targetData = c.machine.CreateTargetData()
|
||||
|
||||
c.mod = llvm.NewModule(pkgName)
|
||||
|
|
|
@ -25,10 +25,11 @@ type TargetSpec struct {
|
|||
// Load a target specification
|
||||
func LoadTarget(target string) (*TargetSpec, error) {
|
||||
spec := &TargetSpec{
|
||||
Triple: target,
|
||||
BuildTags: []string{runtime.GOOS, runtime.GOARCH},
|
||||
Linker: "cc",
|
||||
Objcopy: "objcopy",
|
||||
Triple: target,
|
||||
BuildTags: []string{runtime.GOOS, runtime.GOARCH},
|
||||
Linker: "cc",
|
||||
PreLinkArgs: []string{"-no-pie"}, // WARNING: clang < 5.0 requires -nopie
|
||||
Objcopy: "objcopy",
|
||||
}
|
||||
|
||||
// See whether there is a target specification for this target (e.g.
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче