return n
}
-func elfwriteinterp(ctxt *Link) int {
+func elfwriteinterp() int {
sh := elfshname(".interp")
Cseek(int64(sh.off))
coutbuf.WriteString(interp)
Elfwritedynent(ctxt, s, DT_NULL, 0)
}
-func elfphload(ctxt *Link, seg *Segment) *ElfPhdr {
+func elfphload(seg *Segment) *ElfPhdr {
ph := newElfPhdr()
ph.type_ = PT_LOAD
if seg.Rwx&4 != 0 {
return ph
}
-func elfphrelro(ctxt *Link, seg *Segment) {
+func elfphrelro(seg *Segment) {
ph := newElfPhdr()
ph.type_ = PT_GNU_RELRO
ph.vaddr = seg.Vaddr
return sh
}
-func elfshreloc(ctxt *Link, sect *Section) *ElfShdr {
+func elfshreloc(sect *Section) *ElfShdr {
// If main section is SHT_NOBITS, nothing to relocate.
// Also nothing to relocate in .shstrtab or notes.
if sect.Vaddr >= sect.Seg.Vaddr+sect.Seg.Filelen {
}
// Do not write DT_NULL. elfdynhash will finish it.
-func shsym(ctxt *Link, sh *ElfShdr, s *Symbol) {
+func shsym(sh *ElfShdr, s *Symbol) {
addr := Symaddr(s)
if sh.flags&SHF_ALLOC != 0 {
sh.addr = uint64(addr)
ph.align = sh.addralign
}
-func Asmbelfsetup(ctxt *Link) {
+func Asmbelfsetup() {
/* This null SHdr must appear before all others */
elfshname("")
// Additions to the reserved area must be above this line.
- elfphload(ctxt, &Segtext)
+ elfphload(&Segtext)
if Segrodata.Sect != nil {
- elfphload(ctxt, &Segrodata)
+ elfphload(&Segrodata)
}
if Segrelrodata.Sect != nil {
- elfphload(ctxt, &Segrelrodata)
- elfphrelro(ctxt, &Segrelrodata)
+ elfphload(&Segrelrodata)
+ elfphrelro(&Segrelrodata)
}
- elfphload(ctxt, &Segdata)
+ elfphload(&Segdata)
/* Dynamic linking sections */
if !*FlagD {
sh.link = uint32(elfshname(".dynstr").shnum)
// sh->info = index of first non-local symbol (number of local symbols)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".dynsym", 0))
+ shsym(sh, ctxt.Syms.Lookup(".dynsym", 0))
sh = elfshname(".dynstr")
sh.type_ = SHT_STRTAB
sh.flags = SHF_ALLOC
sh.addralign = 1
- shsym(ctxt, sh, ctxt.Syms.Lookup(".dynstr", 0))
+ shsym(sh, ctxt.Syms.Lookup(".dynstr", 0))
if elfverneed != 0 {
sh := elfshname(".gnu.version")
sh.addralign = 2
sh.link = uint32(elfshname(".dynsym").shnum)
sh.entsize = 2
- shsym(ctxt, sh, ctxt.Syms.Lookup(".gnu.version", 0))
+ shsym(sh, ctxt.Syms.Lookup(".gnu.version", 0))
sh = elfshname(".gnu.version_r")
sh.type_ = SHT_GNU_VERNEED
sh.addralign = uint64(SysArch.RegSize)
sh.info = uint32(elfverneed)
sh.link = uint32(elfshname(".dynstr").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".gnu.version_r", 0))
+ shsym(sh, ctxt.Syms.Lookup(".gnu.version_r", 0))
}
if elfRelType == ".rela" {
sh.addralign = uint64(SysArch.RegSize)
sh.link = uint32(elfshname(".dynsym").shnum)
sh.info = uint32(elfshname(".plt").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".rela.plt", 0))
+ shsym(sh, ctxt.Syms.Lookup(".rela.plt", 0))
sh = elfshname(".rela")
sh.type_ = SHT_RELA
sh.entsize = ELF64RELASIZE
sh.addralign = 8
sh.link = uint32(elfshname(".dynsym").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".rela", 0))
+ shsym(sh, ctxt.Syms.Lookup(".rela", 0))
} else {
sh := elfshname(".rel.plt")
sh.type_ = SHT_REL
sh.entsize = ELF32RELSIZE
sh.addralign = 4
sh.link = uint32(elfshname(".dynsym").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".rel.plt", 0))
+ shsym(sh, ctxt.Syms.Lookup(".rel.plt", 0))
sh = elfshname(".rel")
sh.type_ = SHT_REL
sh.entsize = ELF32RELSIZE
sh.addralign = 4
sh.link = uint32(elfshname(".dynsym").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".rel", 0))
+ shsym(sh, ctxt.Syms.Lookup(".rel", 0))
}
if eh.machine == EM_PPC64 {
sh.type_ = SHT_PROGBITS
sh.flags = SHF_ALLOC + SHF_EXECINSTR
sh.addralign = 4
- shsym(ctxt, sh, ctxt.Syms.Lookup(".glink", 0))
+ shsym(sh, ctxt.Syms.Lookup(".glink", 0))
}
sh = elfshname(".plt")
sh.entsize = 4
}
sh.addralign = sh.entsize
- shsym(ctxt, sh, ctxt.Syms.Lookup(".plt", 0))
+ shsym(sh, ctxt.Syms.Lookup(".plt", 0))
// On ppc64, .got comes from the input files, so don't
// create it here, and .got.plt is not used.
sh.flags = SHF_ALLOC + SHF_WRITE
sh.entsize = uint64(SysArch.RegSize)
sh.addralign = uint64(SysArch.RegSize)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".got", 0))
+ shsym(sh, ctxt.Syms.Lookup(".got", 0))
sh = elfshname(".got.plt")
sh.type_ = SHT_PROGBITS
sh.flags = SHF_ALLOC + SHF_WRITE
sh.entsize = uint64(SysArch.RegSize)
sh.addralign = uint64(SysArch.RegSize)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".got.plt", 0))
+ shsym(sh, ctxt.Syms.Lookup(".got.plt", 0))
}
sh = elfshname(".hash")
sh.entsize = 4
sh.addralign = uint64(SysArch.RegSize)
sh.link = uint32(elfshname(".dynsym").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".hash", 0))
+ shsym(sh, ctxt.Syms.Lookup(".hash", 0))
/* sh and PT_DYNAMIC for .dynamic section */
sh = elfshname(".dynamic")
sh.entsize = 2 * uint64(SysArch.RegSize)
sh.addralign = uint64(SysArch.RegSize)
sh.link = uint32(elfshname(".dynstr").shnum)
- shsym(ctxt, sh, ctxt.Syms.Lookup(".dynamic", 0))
+ shsym(sh, ctxt.Syms.Lookup(".dynamic", 0))
ph := newElfPhdr()
ph.type_ = PT_DYNAMIC
ph.flags = PF_R + PF_W
sh := elfshname(".shstrtab")
sh.type_ = SHT_STRTAB
sh.addralign = 1
- shsym(ctxt, sh, ctxt.Syms.Lookup(".shstrtab", 0))
+ shsym(sh, ctxt.Syms.Lookup(".shstrtab", 0))
eh.shstrndx = uint16(sh.shnum)
// put these sections early in the list
if Linkmode == LinkExternal {
for sect := Segtext.Sect; sect != nil; sect = sect.Next {
- elfshreloc(ctxt, sect)
+ elfshreloc(sect)
}
for sect := Segrodata.Sect; sect != nil; sect = sect.Next {
- elfshreloc(ctxt, sect)
+ elfshreloc(sect)
}
for sect := Segrelrodata.Sect; sect != nil; sect = sect.Next {
- elfshreloc(ctxt, sect)
+ elfshreloc(sect)
}
for sect := Segdata.Sect; sect != nil; sect = sect.Next {
- elfshreloc(ctxt, sect)
+ elfshreloc(sect)
}
for _, s := range dwarfp {
if len(s.R) > 0 || s.Type == obj.SDWARFINFO {
- elfshreloc(ctxt, s.Sect)
+ elfshreloc(s.Sect)
}
if s.Type == obj.SDWARFINFO {
break
a += int64(elfwritephdrs())
a += int64(elfwriteshdrs())
if !*FlagD {
- a += int64(elfwriteinterp(ctxt))
+ a += int64(elfwriteinterp())
}
if Linkmode != LinkExternal {
if Headtype == obj.Hnetbsd {