Commit 7ac67b55 authored by Ian Lance Taylor's avatar Ian Lance Taylor

cmd/internal/ld: change elf64 from int to bool

Change-Id: Iaf2dba7d699a8d52f91ce10222ab0d1a0f1f21fc
Reviewed-on: https://go-review.googlesource.com/8625Reviewed-by: 's avatarJosh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: 's avatarMinux Ma <minux@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 3a84e330
...@@ -725,7 +725,7 @@ var Iself bool ...@@ -725,7 +725,7 @@ var Iself bool
var Nelfsym int = 1 var Nelfsym int = 1
var elf64 int var elf64 bool
var ehdr ElfEhdr var ehdr ElfEhdr
...@@ -764,7 +764,7 @@ func Elfinit() { ...@@ -764,7 +764,7 @@ func Elfinit() {
fallthrough fallthrough
case '6', '7': case '6', '7':
elf64 = 1 elf64 = true
ehdr.phoff = ELF64HDRSIZE /* Must be be ELF64HDRSIZE: first PHdr must follow ELF header */ ehdr.phoff = ELF64HDRSIZE /* Must be be ELF64HDRSIZE: first PHdr must follow ELF header */
ehdr.shoff = ELF64HDRSIZE /* Will move as we add PHeaders */ ehdr.shoff = ELF64HDRSIZE /* Will move as we add PHeaders */
...@@ -854,7 +854,7 @@ func elf32shdr(e *ElfShdr) { ...@@ -854,7 +854,7 @@ func elf32shdr(e *ElfShdr) {
} }
func elfwriteshdrs() uint32 { func elfwriteshdrs() uint32 {
if elf64 != 0 { if elf64 {
for i := 0; i < int(ehdr.shnum); i++ { for i := 0; i < int(ehdr.shnum); i++ {
elf64shdr(shdr[i]) elf64shdr(shdr[i])
} }
...@@ -879,7 +879,7 @@ func elfsetstring(s string, off int) { ...@@ -879,7 +879,7 @@ func elfsetstring(s string, off int) {
} }
func elfwritephdrs() uint32 { func elfwritephdrs() uint32 {
if elf64 != 0 { if elf64 {
for i := 0; i < int(ehdr.phnum); i++ { for i := 0; i < int(ehdr.phnum); i++ {
elf64phdr(phdr[i]) elf64phdr(phdr[i])
} }
...@@ -900,7 +900,7 @@ func newElfPhdr() *ElfPhdr { ...@@ -900,7 +900,7 @@ func newElfPhdr() *ElfPhdr {
phdr[ehdr.phnum] = e phdr[ehdr.phnum] = e
ehdr.phnum++ ehdr.phnum++
} }
if elf64 != 0 { if elf64 {
ehdr.shoff += ELF64PHDRSIZE ehdr.shoff += ELF64PHDRSIZE
} else { } else {
ehdr.shoff += ELF32PHDRSIZE ehdr.shoff += ELF32PHDRSIZE
...@@ -967,7 +967,7 @@ func elf32writehdr() uint32 { ...@@ -967,7 +967,7 @@ func elf32writehdr() uint32 {
} }
func elfwritehdr() uint32 { func elfwritehdr() uint32 {
if elf64 != 0 { if elf64 {
return elf64writehdr() return elf64writehdr()
} }
return elf32writehdr() return elf32writehdr()
...@@ -991,7 +991,7 @@ func elfhash(name []byte) uint32 { ...@@ -991,7 +991,7 @@ func elfhash(name []byte) uint32 {
} }
func Elfwritedynent(s *LSym, tag int, val uint64) { func Elfwritedynent(s *LSym, tag int, val uint64) {
if elf64 != 0 { if elf64 {
Adduint64(Ctxt, s, uint64(tag)) Adduint64(Ctxt, s, uint64(tag))
Adduint64(Ctxt, s, val) Adduint64(Ctxt, s, val)
} else { } else {
...@@ -1005,7 +1005,7 @@ func elfwritedynentsym(s *LSym, tag int, t *LSym) { ...@@ -1005,7 +1005,7 @@ func elfwritedynentsym(s *LSym, tag int, t *LSym) {
} }
func Elfwritedynentsymplus(s *LSym, tag int, t *LSym, add int64) { func Elfwritedynentsymplus(s *LSym, tag int, t *LSym, add int64) {
if elf64 != 0 { if elf64 {
Adduint64(Ctxt, s, uint64(tag)) Adduint64(Ctxt, s, uint64(tag))
} else { } else {
Adduint32(Ctxt, s, uint32(tag)) Adduint32(Ctxt, s, uint32(tag))
...@@ -1014,7 +1014,7 @@ func Elfwritedynentsymplus(s *LSym, tag int, t *LSym, add int64) { ...@@ -1014,7 +1014,7 @@ func Elfwritedynentsymplus(s *LSym, tag int, t *LSym, add int64) {
} }
func elfwritedynentsymsize(s *LSym, tag int, t *LSym) { func elfwritedynentsymsize(s *LSym, tag int, t *LSym) {
if elf64 != 0 { if elf64 {
Adduint64(Ctxt, s, uint64(tag)) Adduint64(Ctxt, s, uint64(tag))
} else { } else {
Adduint32(Ctxt, s, uint32(tag)) Adduint32(Ctxt, s, uint32(tag))
...@@ -2015,7 +2015,7 @@ func Asmbelf(symo int64) { ...@@ -2015,7 +2015,7 @@ func Asmbelf(symo int64) {
sh := elfshname(".dynsym") sh := elfshname(".dynsym")
sh.type_ = SHT_DYNSYM sh.type_ = SHT_DYNSYM
sh.flags = SHF_ALLOC sh.flags = SHF_ALLOC
if elf64 != 0 { if elf64 {
sh.entsize = ELF64SYMSIZE sh.entsize = ELF64SYMSIZE
} else { } else {
sh.entsize = ELF32SYMSIZE sh.entsize = ELF32SYMSIZE
...@@ -2266,7 +2266,7 @@ elfobj: ...@@ -2266,7 +2266,7 @@ elfobj:
} else if HEADTYPE == Hdragonfly { } else if HEADTYPE == Hdragonfly {
eh.ident[EI_OSABI] = ELFOSABI_NONE eh.ident[EI_OSABI] = ELFOSABI_NONE
} }
if elf64 != 0 { if elf64 {
eh.ident[EI_CLASS] = ELFCLASS64 eh.ident[EI_CLASS] = ELFCLASS64
} else { } else {
eh.ident[EI_CLASS] = ELFCLASS32 eh.ident[EI_CLASS] = ELFCLASS32
......
...@@ -167,7 +167,7 @@ func putelfsectionsym(s *LSym, shndx int) { ...@@ -167,7 +167,7 @@ func putelfsectionsym(s *LSym, shndx int) {
func putelfsymshndx(sympos int64, shndx int) { func putelfsymshndx(sympos int64, shndx int) {
here := Cpos() here := Cpos()
if elf64 != 0 { if elf64 {
Cseek(sympos + 6) Cseek(sympos + 6)
} else { } else {
Cseek(sympos + 14) Cseek(sympos + 14)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment