2015-02-27 22:57:28 -05:00
|
|
|
// Inferno utils/5l/obj.c
|
2016-08-28 17:04:46 -07:00
|
|
|
// https://bitbucket.org/inferno-os/inferno-os/src/default/utils/5l/obj.c
|
2015-02-27 22:57:28 -05:00
|
|
|
//
|
|
|
|
|
// Copyright © 1994-1999 Lucent Technologies Inc. All rights reserved.
|
|
|
|
|
// Portions Copyright © 1995-1997 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Portions Copyright © 1997-1999 Vita Nuova Limited
|
|
|
|
|
// Portions Copyright © 2000-2007 Vita Nuova Holdings Limited (www.vitanuova.com)
|
|
|
|
|
// Portions Copyright © 2004,2006 Bruce Ellis
|
|
|
|
|
// Portions Copyright © 2005-2007 C H Forsyth (forsyth@terzarima.net)
|
|
|
|
|
// Revisions Copyright © 2000-2007 Lucent Technologies Inc. and others
|
2016-04-10 14:32:26 -07:00
|
|
|
// Portions Copyright © 2009 The Go Authors. All rights reserved.
|
2015-02-27 22:57:28 -05:00
|
|
|
//
|
|
|
|
|
// Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
|
|
|
// of this software and associated documentation files (the "Software"), to deal
|
|
|
|
|
// in the Software without restriction, including without limitation the rights
|
|
|
|
|
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
|
|
|
// copies of the Software, and to permit persons to whom the Software is
|
|
|
|
|
// furnished to do so, subject to the following conditions:
|
|
|
|
|
//
|
|
|
|
|
// The above copyright notice and this permission notice shall be included in
|
|
|
|
|
// all copies or substantial portions of the Software.
|
|
|
|
|
//
|
|
|
|
|
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
|
|
|
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
|
|
|
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
|
|
|
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
|
|
|
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
|
|
|
// THE SOFTWARE.
|
|
|
|
|
|
2015-05-21 13:28:10 -04:00
|
|
|
package arm
|
2015-02-27 22:57:28 -05:00
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"cmd/internal/obj"
|
2016-04-06 12:01:40 -07:00
|
|
|
"cmd/internal/sys"
|
2015-05-21 13:28:10 -04:00
|
|
|
"cmd/link/internal/ld"
|
2015-02-27 22:57:28 -05:00
|
|
|
"fmt"
|
|
|
|
|
)
|
|
|
|
|
|
2016-09-09 12:04:22 -04:00
|
|
|
func Init() {
|
2016-04-06 12:01:40 -07:00
|
|
|
ld.SysArch = sys.ArchARM
|
2015-02-27 22:57:28 -05:00
|
|
|
|
2016-10-19 12:47:59 -07:00
|
|
|
ld.Thearch.Funcalign = funcAlign
|
|
|
|
|
ld.Thearch.Maxalign = maxAlign
|
|
|
|
|
ld.Thearch.Minalign = minAlign
|
|
|
|
|
ld.Thearch.Dwarfregsp = dwarfRegSP
|
|
|
|
|
ld.Thearch.Dwarfreglr = dwarfRegLR
|
2015-02-27 22:57:28 -05:00
|
|
|
|
|
|
|
|
ld.Thearch.Adddynrel = adddynrel
|
|
|
|
|
ld.Thearch.Archinit = archinit
|
|
|
|
|
ld.Thearch.Archreloc = archreloc
|
|
|
|
|
ld.Thearch.Archrelocvariant = archrelocvariant
|
2016-09-14 14:47:12 -04:00
|
|
|
ld.Thearch.Trampoline = trampoline
|
2015-02-27 22:57:28 -05:00
|
|
|
ld.Thearch.Asmb = asmb
|
|
|
|
|
ld.Thearch.Elfreloc1 = elfreloc1
|
|
|
|
|
ld.Thearch.Elfsetupplt = elfsetupplt
|
|
|
|
|
ld.Thearch.Gentext = gentext
|
|
|
|
|
ld.Thearch.Machoreloc1 = machoreloc1
|
|
|
|
|
ld.Thearch.Lput = ld.Lputl
|
|
|
|
|
ld.Thearch.Wput = ld.Wputl
|
|
|
|
|
ld.Thearch.Vput = ld.Vputl
|
2016-02-29 12:40:23 -09:00
|
|
|
ld.Thearch.Append16 = ld.Append16l
|
|
|
|
|
ld.Thearch.Append32 = ld.Append32l
|
|
|
|
|
ld.Thearch.Append64 = ld.Append64l
|
2015-02-27 22:57:28 -05:00
|
|
|
|
|
|
|
|
ld.Thearch.Linuxdynld = "/lib/ld-linux.so.3" // 2 for OABI, 3 for EABI
|
|
|
|
|
ld.Thearch.Freebsddynld = "/usr/libexec/ld-elf.so.1"
|
2014-12-24 02:08:58 +11:00
|
|
|
ld.Thearch.Openbsddynld = "/usr/libexec/ld.so"
|
2015-02-27 22:57:28 -05:00
|
|
|
ld.Thearch.Netbsddynld = "/libexec/ld.elf_so"
|
|
|
|
|
ld.Thearch.Dragonflydynld = "XXX"
|
|
|
|
|
ld.Thearch.Solarisdynld = "XXX"
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-21 13:52:23 -04:00
|
|
|
func archinit(ctxt *ld.Link) {
|
2016-09-09 06:20:44 -04:00
|
|
|
switch ld.Headtype {
|
2015-02-27 22:57:28 -05:00
|
|
|
default:
|
2016-09-09 06:20:44 -04:00
|
|
|
ld.Exitf("unknown -H option: %v", ld.Headtype)
|
2015-02-27 22:57:28 -05:00
|
|
|
|
2015-04-19 19:33:58 -07:00
|
|
|
case obj.Hplan9: /* plan 9 */
|
2015-02-27 22:57:28 -05:00
|
|
|
ld.HEADR = 32
|
|
|
|
|
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagTextAddr == -1 {
|
|
|
|
|
*ld.FlagTextAddr = 4128
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagDataAddr == -1 {
|
|
|
|
|
*ld.FlagDataAddr = 0
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagRound == -1 {
|
|
|
|
|
*ld.FlagRound = 4096
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
|
|
|
|
|
2015-04-19 19:33:58 -07:00
|
|
|
case obj.Hlinux, /* arm elf */
|
|
|
|
|
obj.Hfreebsd,
|
|
|
|
|
obj.Hnetbsd,
|
|
|
|
|
obj.Hopenbsd:
|
2016-08-21 18:34:24 -04:00
|
|
|
*ld.FlagD = false
|
2015-02-27 22:57:28 -05:00
|
|
|
// with dynamic linking
|
2016-08-21 13:52:23 -04:00
|
|
|
ld.Elfinit(ctxt)
|
2015-02-27 22:57:28 -05:00
|
|
|
ld.HEADR = ld.ELFRESERVE
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagTextAddr == -1 {
|
|
|
|
|
*ld.FlagTextAddr = 0x10000 + int64(ld.HEADR)
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagDataAddr == -1 {
|
|
|
|
|
*ld.FlagDataAddr = 0
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagRound == -1 {
|
2017-01-04 09:24:33 -05:00
|
|
|
*ld.FlagRound = 0x10000
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
|
|
|
|
|
2015-04-19 19:33:58 -07:00
|
|
|
case obj.Hnacl:
|
2016-08-21 13:52:23 -04:00
|
|
|
ld.Elfinit(ctxt)
|
2015-02-27 22:57:28 -05:00
|
|
|
ld.HEADR = 0x10000
|
|
|
|
|
ld.Funcalign = 16
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagTextAddr == -1 {
|
|
|
|
|
*ld.FlagTextAddr = 0x20000
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagDataAddr == -1 {
|
|
|
|
|
*ld.FlagDataAddr = 0
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagRound == -1 {
|
|
|
|
|
*ld.FlagRound = 0x10000
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
|
|
|
|
|
2015-04-19 19:33:58 -07:00
|
|
|
case obj.Hdarwin: /* apple MACH */
|
2016-08-21 18:34:24 -04:00
|
|
|
*ld.FlagW = true // disable DWARF generation
|
2015-02-27 22:57:28 -05:00
|
|
|
ld.Machoinit()
|
|
|
|
|
ld.HEADR = ld.INITIAL_MACHO_HEADR
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagTextAddr == -1 {
|
|
|
|
|
*ld.FlagTextAddr = 4096 + int64(ld.HEADR)
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagDataAddr == -1 {
|
|
|
|
|
*ld.FlagDataAddr = 0
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagRound == -1 {
|
|
|
|
|
*ld.FlagRound = 4096
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2016-08-21 18:34:24 -04:00
|
|
|
if *ld.FlagDataAddr != 0 && *ld.FlagRound != 0 {
|
|
|
|
|
fmt.Printf("warning: -D0x%x is ignored because of -R0x%x\n", uint64(*ld.FlagDataAddr), uint32(*ld.FlagRound))
|
2015-02-27 22:57:28 -05:00
|
|
|
}
|
|
|
|
|
}
|