mirror of
https://github.com/golang/go
synced 2024-10-14 03:43:28 +00:00
liblink: remove arch-specific constants from file format
The relocation and automatic variable types were using arch-specific numbers. Introduce portable enumerations instead. To the best of my knowledge, these are the only arch-specific bits left in the new object file format. Remove now, before Go 1.3, because file formats are forever. LGTM=iant R=iant CC=golang-codereviews https://golang.org/cl/87670044
This commit is contained in:
parent
b53bb2cae5
commit
8d39e55c65
|
@ -223,6 +223,28 @@ enum
|
|||
SHIDDEN = 1<<9, // hidden or local symbol
|
||||
};
|
||||
|
||||
// Reloc.type
|
||||
enum
|
||||
{
|
||||
R_ADDR = 1,
|
||||
R_SIZE,
|
||||
R_CALL,
|
||||
R_CONST,
|
||||
R_PCREL,
|
||||
R_TLS,
|
||||
R_GOTOFF,
|
||||
R_PLT0,
|
||||
R_PLT1,
|
||||
R_PLT2,
|
||||
};
|
||||
|
||||
// Auto.type
|
||||
enum
|
||||
{
|
||||
A_AUTO = 1,
|
||||
A_PARAM,
|
||||
};
|
||||
|
||||
struct Auto
|
||||
{
|
||||
LSym* asym;
|
||||
|
@ -420,14 +442,14 @@ struct LinkArch
|
|||
|
||||
// TODO: Give these the same values on all systems.
|
||||
int D_ADDR;
|
||||
int D_AUTO;
|
||||
int D_BRANCH;
|
||||
int D_CONST;
|
||||
int D_EXTERN;
|
||||
int D_FCONST;
|
||||
int D_NONE;
|
||||
int D_PCREL;
|
||||
int D_PARAM;
|
||||
int D_SCONST;
|
||||
int D_SIZE;
|
||||
int D_STATIC;
|
||||
|
||||
int ACALL;
|
||||
|
|
|
@ -271,16 +271,6 @@ enum
|
|||
D_STATIC = (D_NONE+4),
|
||||
D_AUTO = (D_NONE+5),
|
||||
D_PARAM = (D_NONE+6),
|
||||
|
||||
/* internal only */
|
||||
D_SIZE = (D_NONE+40),
|
||||
D_PCREL = (D_NONE+41),
|
||||
D_GOTOFF = (D_NONE+42), // R_ARM_GOTOFF
|
||||
D_PLT0 = (D_NONE+43), // R_ARM_PLT32, 1st inst: add ip, pc, #0xNN00000
|
||||
D_PLT1 = (D_NONE+44), // R_ARM_PLT32, 2nd inst: add ip, ip, #0xNN000
|
||||
D_PLT2 = (D_NONE+45), // R_ARM_PLT32, 3rd inst: ldr pc, [ip, #0xNNN]!
|
||||
D_CALL = (D_NONE+46), // R_ARM_PLT32/R_ARM_CALL/R_ARM_JUMP24, bl xxxxx or b yyyyy
|
||||
D_TLS = (D_NONE+47), // R_ARM_TLS_LE32/R_ARM_TLS_IE32
|
||||
};
|
||||
|
||||
/*
|
||||
|
|
|
@ -102,7 +102,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
|
||||
// Handle relocations found in ELF object files.
|
||||
case 256 + R_ARM_PLT32:
|
||||
r->type = D_CALL;
|
||||
r->type = R_CALL;
|
||||
if(targ->type == SDYNIMPORT) {
|
||||
addpltsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
|
@ -121,7 +121,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
} else {
|
||||
addgotsym(ctxt, targ);
|
||||
}
|
||||
r->type = D_CONST; // write r->add during relocsym
|
||||
r->type = R_CONST; // write r->add during relocsym
|
||||
r->sym = S;
|
||||
r->add += targ->got;
|
||||
return;
|
||||
|
@ -132,23 +132,23 @@ adddynrel(LSym *s, Reloc *r)
|
|||
} else {
|
||||
addgotsym(ctxt, targ);
|
||||
}
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->sym = linklookup(ctxt, ".got", 0);
|
||||
r->add += targ->got + 4;
|
||||
return;
|
||||
|
||||
case 256 + R_ARM_GOTOFF: // R_ARM_GOTOFF32
|
||||
r->type = D_GOTOFF;
|
||||
r->type = R_GOTOFF;
|
||||
return;
|
||||
|
||||
case 256 + R_ARM_GOTPC: // R_ARM_BASE_PREL
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->sym = linklookup(ctxt, ".got", 0);
|
||||
r->add += 4;
|
||||
return;
|
||||
|
||||
case 256 + R_ARM_CALL:
|
||||
r->type = D_CALL;
|
||||
r->type = R_CALL;
|
||||
if(targ->type == SDYNIMPORT) {
|
||||
addpltsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
|
@ -157,14 +157,14 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
|
||||
case 256 + R_ARM_REL32: // R_ARM_REL32
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->add += 4;
|
||||
return;
|
||||
|
||||
case 256 + R_ARM_ABS32:
|
||||
if(targ->type == SDYNIMPORT)
|
||||
diag("unexpected R_ARM_ABS32 relocation for dynamic symbol %s", targ->name);
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
return;
|
||||
|
||||
case 256 + R_ARM_V4BX:
|
||||
|
@ -178,7 +178,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
|
||||
case 256 + R_ARM_PC24:
|
||||
case 256 + R_ARM_JUMP24:
|
||||
r->type = D_CALL;
|
||||
r->type = R_CALL;
|
||||
if(targ->type == SDYNIMPORT) {
|
||||
addpltsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
|
@ -192,13 +192,13 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
|
||||
switch(r->type) {
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
addpltsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
r->add = targ->plt;
|
||||
return;
|
||||
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(s->type != SDATA)
|
||||
break;
|
||||
if(iself) {
|
||||
|
@ -206,7 +206,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
rel = linklookup(ctxt, ".rel", 0);
|
||||
addaddrplus(ctxt, rel, s, r->off);
|
||||
adduint32(ctxt, rel, ELF32_R_INFO(targ->dynid, R_ARM_GLOB_DAT)); // we need a S + A dynmic reloc
|
||||
r->type = D_CONST; // write r->add during relocsym
|
||||
r->type = R_CONST; // write r->add during relocsym
|
||||
r->sym = S;
|
||||
return;
|
||||
}
|
||||
|
@ -229,21 +229,21 @@ elfreloc1(Reloc *r, vlong sectoff)
|
|||
default:
|
||||
return -1;
|
||||
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(r->siz == 4)
|
||||
LPUT(R_ARM_ABS32 | elfsym<<8);
|
||||
else
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
if(r->siz == 4)
|
||||
LPUT(R_ARM_REL32 | elfsym<<8);
|
||||
else
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case D_CALL:
|
||||
case R_CALL:
|
||||
if(r->siz == 4) {
|
||||
if((r->add & 0xff000000) == 0xeb000000) // BL
|
||||
LPUT(R_ARM_CALL | elfsym<<8);
|
||||
|
@ -253,7 +253,7 @@ elfreloc1(Reloc *r, vlong sectoff)
|
|||
return -1;
|
||||
break;
|
||||
|
||||
case D_TLS:
|
||||
case R_TLS:
|
||||
if(r->siz == 4) {
|
||||
if(flag_shared)
|
||||
LPUT(R_ARM_TLS_IE32 | elfsym<<8);
|
||||
|
@ -310,7 +310,7 @@ archreloc(Reloc *r, LSym *s, vlong *val)
|
|||
|
||||
if(linkmode == LinkExternal) {
|
||||
switch(r->type) {
|
||||
case D_CALL:
|
||||
case R_CALL:
|
||||
r->done = 0;
|
||||
|
||||
// set up addend for eventual relocation via outer symbol.
|
||||
|
@ -335,29 +335,29 @@ archreloc(Reloc *r, LSym *s, vlong *val)
|
|||
return -1;
|
||||
}
|
||||
switch(r->type) {
|
||||
case D_CONST:
|
||||
case R_CONST:
|
||||
*val = r->add;
|
||||
return 0;
|
||||
case D_GOTOFF:
|
||||
case R_GOTOFF:
|
||||
*val = symaddr(r->sym) + r->add - symaddr(linklookup(ctxt, ".got", 0));
|
||||
return 0;
|
||||
// The following three arch specific relocations are only for generation of
|
||||
// Linux/ARM ELF's PLT entry (3 assembler instruction)
|
||||
case D_PLT0: // add ip, pc, #0xXX00000
|
||||
case R_PLT0: // add ip, pc, #0xXX00000
|
||||
if (symaddr(linklookup(ctxt, ".got.plt", 0)) < symaddr(linklookup(ctxt, ".plt", 0)))
|
||||
diag(".got.plt should be placed after .plt section.");
|
||||
*val = 0xe28fc600U +
|
||||
(0xff & ((uint32)(symaddr(r->sym) - (symaddr(linklookup(ctxt, ".plt", 0)) + r->off) + r->add) >> 20));
|
||||
return 0;
|
||||
case D_PLT1: // add ip, ip, #0xYY000
|
||||
case R_PLT1: // add ip, ip, #0xYY000
|
||||
*val = 0xe28cca00U +
|
||||
(0xff & ((uint32)(symaddr(r->sym) - (symaddr(linklookup(ctxt, ".plt", 0)) + r->off) + r->add + 4) >> 12));
|
||||
return 0;
|
||||
case D_PLT2: // ldr pc, [ip, #0xZZZ]!
|
||||
case R_PLT2: // ldr pc, [ip, #0xZZZ]!
|
||||
*val = 0xe5bcf000U +
|
||||
(0xfff & (uint32)(symaddr(r->sym) - (symaddr(linklookup(ctxt, ".plt", 0)) + r->off) + r->add + 8));
|
||||
return 0;
|
||||
case D_CALL: // bl XXXXXX or b YYYYYY
|
||||
case R_CALL: // bl XXXXXX or b YYYYYY
|
||||
*val = braddoff((0xff000000U & (uint32)r->add),
|
||||
(0xffffff & (uint32)
|
||||
((symaddr(r->sym) + ((uint32)r->add) * 4 - (s->value + r->off)) / 4)));
|
||||
|
@ -411,9 +411,9 @@ addpltsym(Link *ctxt, LSym *s)
|
|||
|
||||
// .plt entry, this depends on the .got entry
|
||||
s->plt = plt->size;
|
||||
addpltreloc(ctxt, plt, got, s, D_PLT0); // add lr, pc, #0xXX00000
|
||||
addpltreloc(ctxt, plt, got, s, D_PLT1); // add lr, lr, #0xYY000
|
||||
addpltreloc(ctxt, plt, got, s, D_PLT2); // ldr pc, [lr, #0xZZZ]!
|
||||
addpltreloc(ctxt, plt, got, s, R_PLT0); // add lr, pc, #0xXX00000
|
||||
addpltreloc(ctxt, plt, got, s, R_PLT1); // add lr, lr, #0xYY000
|
||||
addpltreloc(ctxt, plt, got, s, R_PLT2); // ldr pc, [lr, #0xZZZ]!
|
||||
|
||||
// rel
|
||||
addaddrplus(ctxt, rel, got, s->got);
|
||||
|
|
|
@ -867,10 +867,6 @@ enum
|
|||
|
||||
D_INDIR, /* additive */
|
||||
|
||||
D_SIZE = D_INDIR + D_INDIR, /* 6l internal */
|
||||
D_PCREL,
|
||||
D_TLS,
|
||||
|
||||
T_TYPE = 1<<0,
|
||||
T_INDEX = 1<<1,
|
||||
T_OFFSET = 1<<2,
|
||||
|
|
|
@ -103,12 +103,12 @@ adddynrel(LSym *s, Reloc *r)
|
|||
diag("unexpected R_X86_64_PC32 relocation for dynamic symbol %s", targ->name);
|
||||
if(targ->type == 0 || targ->type == SXREF)
|
||||
diag("unknown symbol %s in pcrel", targ->name);
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->add += 4;
|
||||
return;
|
||||
|
||||
case 256 + R_X86_64_PLT32:
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->add += 4;
|
||||
if(targ->type == SDYNIMPORT) {
|
||||
addpltsym(targ);
|
||||
|
@ -123,7 +123,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
if(r->off >= 2 && s->p[r->off-2] == 0x8b) {
|
||||
// turn MOVQ of GOT entry into LEAQ of symbol itself
|
||||
s->p[r->off-2] = 0x8d;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->add += 4;
|
||||
return;
|
||||
}
|
||||
|
@ -131,7 +131,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
// TODO: just needs relocation, no need to put in .dynsym
|
||||
}
|
||||
addgotsym(targ);
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->sym = linklookup(ctxt, ".got", 0);
|
||||
r->add += 4;
|
||||
r->add += targ->got;
|
||||
|
@ -140,7 +140,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
case 256 + R_X86_64_64:
|
||||
if(targ->type == SDYNIMPORT)
|
||||
diag("unexpected R_X86_64_64 relocation for dynamic symbol %s", targ->name);
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
return;
|
||||
|
||||
// Handle relocations found in Mach-O object files.
|
||||
|
@ -148,7 +148,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
case 512 + MACHO_X86_64_RELOC_SIGNED*2 + 0:
|
||||
case 512 + MACHO_X86_64_RELOC_BRANCH*2 + 0:
|
||||
// TODO: What is the difference between all these?
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
if(targ->type == SDYNIMPORT)
|
||||
diag("unexpected reloc for dynamic symbol %s", targ->name);
|
||||
return;
|
||||
|
@ -158,7 +158,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
addpltsym(targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
r->add = targ->plt;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
return;
|
||||
}
|
||||
// fall through
|
||||
|
@ -167,7 +167,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
case 512 + MACHO_X86_64_RELOC_SIGNED_1*2 + 1:
|
||||
case 512 + MACHO_X86_64_RELOC_SIGNED_2*2 + 1:
|
||||
case 512 + MACHO_X86_64_RELOC_SIGNED_4*2 + 1:
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
if(targ->type == SDYNIMPORT)
|
||||
diag("unexpected pc-relative reloc for dynamic symbol %s", targ->name);
|
||||
return;
|
||||
|
@ -181,7 +181,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
}
|
||||
s->p[r->off-2] = 0x8d;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
return;
|
||||
}
|
||||
// fall through
|
||||
|
@ -189,7 +189,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
if(targ->type != SDYNIMPORT)
|
||||
diag("unexpected GOT reloc for non-dynamic symbol %s", targ->name);
|
||||
addgotsym(targ);
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->sym = linklookup(ctxt, ".got", 0);
|
||||
r->add += targ->got;
|
||||
return;
|
||||
|
@ -200,13 +200,13 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
|
||||
switch(r->type) {
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
addpltsym(targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
r->add = targ->plt;
|
||||
return;
|
||||
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(s->type == STEXT && iself) {
|
||||
// The code is asking for the address of an external
|
||||
// function. We provide it with the address of the
|
||||
|
@ -272,7 +272,7 @@ elfreloc1(Reloc *r, vlong sectoff)
|
|||
default:
|
||||
return -1;
|
||||
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(r->siz == 4)
|
||||
VPUT(R_X86_64_32 | (uint64)elfsym<<32);
|
||||
else if(r->siz == 8)
|
||||
|
@ -281,7 +281,7 @@ elfreloc1(Reloc *r, vlong sectoff)
|
|||
return -1;
|
||||
break;
|
||||
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
if(r->siz == 4) {
|
||||
if(r->xsym->type == SDYNIMPORT)
|
||||
VPUT(R_X86_64_GOTPCREL | (uint64)elfsym<<32);
|
||||
|
@ -291,7 +291,7 @@ elfreloc1(Reloc *r, vlong sectoff)
|
|||
return -1;
|
||||
break;
|
||||
|
||||
case D_TLS:
|
||||
case R_TLS:
|
||||
if(r->siz == 4) {
|
||||
if(flag_shared)
|
||||
VPUT(R_X86_64_GOTTPOFF | (uint64)elfsym<<32);
|
||||
|
@ -332,10 +332,10 @@ machoreloc1(Reloc *r, vlong sectoff)
|
|||
switch(r->type) {
|
||||
default:
|
||||
return -1;
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
v |= MACHO_X86_64_RELOC_UNSIGNED<<28;
|
||||
break;
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
v |= 1<<24; // pc-relative bit
|
||||
v |= MACHO_X86_64_RELOC_BRANCH<<28;
|
||||
break;
|
||||
|
|
|
@ -655,11 +655,6 @@ enum
|
|||
D_INDIR, /* additive */
|
||||
|
||||
D_CONST2 = D_INDIR+D_INDIR,
|
||||
D_SIZE, /* 8l internal */
|
||||
D_PCREL,
|
||||
D_GOTOFF,
|
||||
D_GOTREL,
|
||||
D_TLS,
|
||||
|
||||
T_TYPE = 1<<0,
|
||||
T_INDEX = 1<<1,
|
||||
|
|
|
@ -100,12 +100,12 @@ adddynrel(LSym *s, Reloc *r)
|
|||
diag("unexpected R_386_PC32 relocation for dynamic symbol %s", targ->name);
|
||||
if(targ->type == 0 || targ->type == SXREF)
|
||||
diag("unknown symbol %s in pcrel", targ->name);
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->add += 4;
|
||||
return;
|
||||
|
||||
case 256 + R_386_PLT32:
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->add += 4;
|
||||
if(targ->type == SDYNIMPORT) {
|
||||
addpltsym(ctxt, targ);
|
||||
|
@ -123,21 +123,21 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
}
|
||||
s->p[r->off-2] = 0x8d;
|
||||
r->type = D_GOTOFF;
|
||||
r->type = R_GOTOFF;
|
||||
return;
|
||||
}
|
||||
addgotsym(ctxt, targ);
|
||||
r->type = D_CONST; // write r->add during relocsym
|
||||
r->type = R_CONST; // write r->add during relocsym
|
||||
r->sym = S;
|
||||
r->add += targ->got;
|
||||
return;
|
||||
|
||||
case 256 + R_386_GOTOFF:
|
||||
r->type = D_GOTOFF;
|
||||
r->type = R_GOTOFF;
|
||||
return;
|
||||
|
||||
case 256 + R_386_GOTPC:
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->sym = linklookup(ctxt, ".got", 0);
|
||||
r->add += 4;
|
||||
return;
|
||||
|
@ -145,11 +145,11 @@ adddynrel(LSym *s, Reloc *r)
|
|||
case 256 + R_386_32:
|
||||
if(targ->type == SDYNIMPORT)
|
||||
diag("unexpected R_386_32 relocation for dynamic symbol %s", targ->name);
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
return;
|
||||
|
||||
case 512 + MACHO_GENERIC_RELOC_VANILLA*2 + 0:
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
if(targ->type == SDYNIMPORT)
|
||||
diag("unexpected reloc for dynamic symbol %s", targ->name);
|
||||
return;
|
||||
|
@ -159,10 +159,10 @@ adddynrel(LSym *s, Reloc *r)
|
|||
addpltsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
r->add = targ->plt;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
return;
|
||||
}
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
return;
|
||||
|
||||
case 512 + MACHO_FAKE_GOTPCREL:
|
||||
|
@ -174,13 +174,13 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
}
|
||||
s->p[r->off-2] = 0x8d;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
return;
|
||||
}
|
||||
addgotsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".got", 0);
|
||||
r->add += targ->got;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -189,13 +189,13 @@ adddynrel(LSym *s, Reloc *r)
|
|||
return;
|
||||
|
||||
switch(r->type) {
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
addpltsym(ctxt, targ);
|
||||
r->sym = linklookup(ctxt, ".plt", 0);
|
||||
r->add = targ->plt;
|
||||
return;
|
||||
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(s->type != SDATA)
|
||||
break;
|
||||
if(iself) {
|
||||
|
@ -203,7 +203,7 @@ adddynrel(LSym *s, Reloc *r)
|
|||
rel = linklookup(ctxt, ".rel", 0);
|
||||
addaddrplus(ctxt, rel, s, r->off);
|
||||
adduint32(ctxt, rel, ELF32_R_INFO(targ->dynid, R_386_32));
|
||||
r->type = D_CONST; // write r->add during relocsym
|
||||
r->type = R_CONST; // write r->add during relocsym
|
||||
r->sym = S;
|
||||
return;
|
||||
}
|
||||
|
@ -249,21 +249,21 @@ elfreloc1(Reloc *r, vlong sectoff)
|
|||
default:
|
||||
return -1;
|
||||
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(r->siz == 4)
|
||||
LPUT(R_386_32 | elfsym<<8);
|
||||
else
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
if(r->siz == 4)
|
||||
LPUT(R_386_PC32 | elfsym<<8);
|
||||
else
|
||||
return -1;
|
||||
break;
|
||||
|
||||
case D_TLS:
|
||||
case R_TLS:
|
||||
if(r->siz == 4)
|
||||
LPUT(R_386_TLS_LE | elfsym<<8);
|
||||
else
|
||||
|
@ -299,10 +299,10 @@ machoreloc1(Reloc *r, vlong sectoff)
|
|||
switch(r->type) {
|
||||
default:
|
||||
return -1;
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
v |= MACHO_GENERIC_RELOC_VANILLA<<28;
|
||||
break;
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
v |= 1<<24; // pc-relative bit
|
||||
v |= MACHO_GENERIC_RELOC_VANILLA<<28;
|
||||
break;
|
||||
|
@ -337,10 +337,10 @@ archreloc(Reloc *r, LSym *s, vlong *val)
|
|||
if(linkmode == LinkExternal)
|
||||
return -1;
|
||||
switch(r->type) {
|
||||
case D_CONST:
|
||||
case R_CONST:
|
||||
*val = r->add;
|
||||
return 0;
|
||||
case D_GOTOFF:
|
||||
case R_GOTOFF:
|
||||
*val = symaddr(r->sym) + r->add - symaddr(linklookup(ctxt, ".got", 0));
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ relocsym(LSym *s)
|
|||
if(archreloc(r, s, &o) < 0)
|
||||
diag("unknown reloc %d", r->type);
|
||||
break;
|
||||
case D_TLS:
|
||||
case R_TLS:
|
||||
if(linkmode == LinkInternal && iself && thechar == '5') {
|
||||
// On ELF ARM, the thread pointer is 8 bytes before
|
||||
// the start of the thread-local data block, so add 8
|
||||
|
@ -183,7 +183,7 @@ relocsym(LSym *s)
|
|||
if(thechar != '6')
|
||||
o = r->add;
|
||||
break;
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
if(linkmode == LinkExternal && r->sym->type != SCONST) {
|
||||
r->done = 0;
|
||||
|
||||
|
@ -212,7 +212,7 @@ relocsym(LSym *s)
|
|||
}
|
||||
o = symaddr(r->sym) + r->add;
|
||||
break;
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
// r->sym can be null when CALL $(constant) is transformed from absolute PC to relative PC call.
|
||||
if(linkmode == LinkExternal && r->sym && r->sym->type != SCONST && r->sym->sect != ctxt->cursym->sect) {
|
||||
r->done = 0;
|
||||
|
@ -253,7 +253,7 @@ relocsym(LSym *s)
|
|||
// the standard host compiler (gcc on most other systems).
|
||||
o += r->add - (s->value + r->off + (int32)r->siz);
|
||||
break;
|
||||
case D_SIZE:
|
||||
case R_SIZE:
|
||||
o = r->sym->size + r->add;
|
||||
break;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@ relocsym(LSym *s)
|
|||
ctxt->cursym = s;
|
||||
diag("bad reloc size %#ux for %s", siz, r->sym->name);
|
||||
case 4:
|
||||
if(r->type == D_PCREL) {
|
||||
if(r->type == R_PCREL) {
|
||||
if(o != (int32)o)
|
||||
diag("pc-relative relocation address is too big: %#llx", o);
|
||||
} else {
|
||||
|
@ -524,10 +524,10 @@ datblk(int32 addr, int32 size)
|
|||
rsname = r->sym->name;
|
||||
typ = "?";
|
||||
switch(r->type) {
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
typ = "addr";
|
||||
break;
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
typ = "pcrel";
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -603,7 +603,7 @@ adddwarfrel(LSym* sec, LSym* sym, vlong offsetbase, int siz, vlong addend)
|
|||
r->xsym = sym;
|
||||
r->off = cpos() - offsetbase;
|
||||
r->siz = siz;
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->add = addend;
|
||||
r->xadd = addend;
|
||||
if(iself && thechar == '6')
|
||||
|
@ -1638,11 +1638,11 @@ writelines(void)
|
|||
memset(varhash, 0, sizeof varhash);
|
||||
for(a = s->autom; a; a = a->link) {
|
||||
switch (a->type) {
|
||||
case D_AUTO:
|
||||
case A_AUTO:
|
||||
dt = DW_ABRV_AUTO;
|
||||
offs = a->aoffset - PtrSize;
|
||||
break;
|
||||
case D_PARAM:
|
||||
case A_PARAM:
|
||||
dt = DW_ABRV_PARAM;
|
||||
offs = a->aoffset;
|
||||
break;
|
||||
|
|
|
@ -744,7 +744,7 @@ ldmacho(Biobuf *f, char *pkg, int64 len, char *pn)
|
|||
// want to make it pc-relative aka relative to rp->off+4
|
||||
// but the scatter asks for relative to off = (rel+1)->value - sect->addr.
|
||||
// adjust rp->add accordingly.
|
||||
rp->type = D_PCREL;
|
||||
rp->type = R_PCREL;
|
||||
rp->add += (rp->off+4) - ((rel+1)->value - sect->addr);
|
||||
|
||||
// now consider the desired symbol.
|
||||
|
|
|
@ -290,18 +290,18 @@ ldpe(Biobuf *f, char *pkg, int64 len, char *pn)
|
|||
case IMAGE_REL_AMD64_REL32:
|
||||
case IMAGE_REL_AMD64_ADDR32: // R_X86_64_PC32
|
||||
case IMAGE_REL_AMD64_ADDR32NB:
|
||||
rp->type = D_PCREL;
|
||||
rp->type = R_PCREL;
|
||||
rp->add = (int32)le32(rsect->base+rp->off);
|
||||
break;
|
||||
case IMAGE_REL_I386_DIR32NB:
|
||||
case IMAGE_REL_I386_DIR32:
|
||||
rp->type = D_ADDR;
|
||||
rp->type = R_ADDR;
|
||||
// load addend from image
|
||||
rp->add = le32(rsect->base+rp->off);
|
||||
break;
|
||||
case IMAGE_REL_AMD64_ADDR64: // R_X86_64_64
|
||||
rp->siz = 8;
|
||||
rp->type = D_ADDR;
|
||||
rp->type = R_ADDR;
|
||||
// load addend from image
|
||||
rp->add = le64(rsect->base+rp->off);
|
||||
break;
|
||||
|
|
|
@ -1358,11 +1358,11 @@ genasmsym(void (*put)(LSym*, char*, int, vlong, vlong, int, LSym*))
|
|||
for(a=s->autom; a; a=a->link) {
|
||||
// Emit a or p according to actual offset, even if label is wrong.
|
||||
// This avoids negative offsets, which cannot be encoded.
|
||||
if(a->type != D_AUTO && a->type != D_PARAM)
|
||||
if(a->type != A_AUTO && a->type != A_PARAM)
|
||||
continue;
|
||||
|
||||
// compute offset relative to FP
|
||||
if(a->type == D_PARAM)
|
||||
if(a->type == A_PARAM)
|
||||
off = a->aoffset;
|
||||
else
|
||||
off = a->aoffset - PtrSize;
|
||||
|
|
|
@ -73,17 +73,11 @@ func (p *Prog) loadPackage(pkg *Package) {
|
|||
}
|
||||
}
|
||||
|
||||
// TODO(rsc): These are the relocation types and should be
|
||||
// loaded from debug/goobj. They are not in debug/goobj
|
||||
// because they are different for each architecture.
|
||||
// The symbol file format needs to be revised to use an
|
||||
// architecture-independent set of numbers, and then
|
||||
// those should be fetched from debug/goobj instead of
|
||||
// defined here. These are the amd64 numbers.
|
||||
// TODO(rsc): Define full enumeration for relocation types.
|
||||
const (
|
||||
D_ADDR = 120
|
||||
D_SIZE = 246
|
||||
D_PCREL = 247
|
||||
R_ADDR = 1
|
||||
R_SIZE = 2
|
||||
R_PCREL = 5
|
||||
)
|
||||
|
||||
// relocateSym applies relocations to sym's data.
|
||||
|
@ -99,9 +93,9 @@ func (p *Prog) relocateSym(sym *Sym, data []byte) {
|
|||
switch r.Type {
|
||||
default:
|
||||
p.errorf("%v: unknown relocation type %d", sym, r.Type)
|
||||
case D_ADDR:
|
||||
case R_ADDR:
|
||||
// ok
|
||||
case D_PCREL:
|
||||
case R_PCREL:
|
||||
val -= sym.Addr + Addr(r.Offset+r.Size)
|
||||
}
|
||||
frag := data[r.Offset : r.Offset+r.Size]
|
||||
|
|
|
@ -371,7 +371,7 @@ func (b *SymBuffer) Addr(off int, sym goobj.SymID, symoff int64) int {
|
|||
Size: b.ptrsize,
|
||||
Sym: sym,
|
||||
Add: int(symoff),
|
||||
Type: D_ADDR,
|
||||
Type: R_ADDR,
|
||||
})
|
||||
return off + b.ptrsize
|
||||
}
|
||||
|
|
BIN
src/cmd/link/testdata/autosection.6
vendored
BIN
src/cmd/link/testdata/autosection.6
vendored
Binary file not shown.
BIN
src/cmd/link/testdata/autoweak.6
vendored
BIN
src/cmd/link/testdata/autoweak.6
vendored
Binary file not shown.
BIN
src/cmd/link/testdata/dead.6
vendored
BIN
src/cmd/link/testdata/dead.6
vendored
Binary file not shown.
BIN
src/cmd/link/testdata/hello.6
vendored
BIN
src/cmd/link/testdata/hello.6
vendored
Binary file not shown.
BIN
src/cmd/link/testdata/layout.6
vendored
BIN
src/cmd/link/testdata/layout.6
vendored
Binary file not shown.
BIN
src/cmd/link/testdata/pclntab.6
vendored
BIN
src/cmd/link/testdata/pclntab.6
vendored
Binary file not shown.
|
@ -1302,7 +1302,7 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
|
|||
rel->siz = 4;
|
||||
rel->sym = p->to.sym;
|
||||
rel->add = o1 | ((v >> 2) & 0xffffff);
|
||||
rel->type = D_CALL;
|
||||
rel->type = R_CALL;
|
||||
break;
|
||||
}
|
||||
if(p->pcond != nil)
|
||||
|
@ -1372,16 +1372,16 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
|
|||
// to the thread-local g and m pointers.
|
||||
// Emit a TLS relocation instead of a standard one.
|
||||
if(rel->sym == ctxt->gmsym) {
|
||||
rel->type = D_TLS;
|
||||
rel->type = R_TLS;
|
||||
if(ctxt->flag_shared)
|
||||
rel->add += ctxt->pc - p->pcrel->pc - 8 - rel->siz;
|
||||
rel->xadd = rel->add;
|
||||
rel->xsym = rel->sym;
|
||||
} else if(ctxt->flag_shared) {
|
||||
rel->type = D_PCREL;
|
||||
rel->type = R_PCREL;
|
||||
rel->add += ctxt->pc - p->pcrel->pc - 8;
|
||||
} else
|
||||
rel->type = D_ADDR;
|
||||
rel->type = R_ADDR;
|
||||
o1 = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -1720,10 +1720,10 @@ if(0 /*debug['G']*/) print("%ux: %s: arm %d\n", (uint32)(p->pc), p->from.sym->na
|
|||
rel->add = p->pcond->pc;
|
||||
}
|
||||
if(o->flag & LPCREL) {
|
||||
rel->type = D_PCREL;
|
||||
rel->type = R_PCREL;
|
||||
rel->add += ctxt->pc - p->pcrel->pc - 16 + rel->siz;
|
||||
} else
|
||||
rel->type = D_ADDR;
|
||||
rel->type = R_ADDR;
|
||||
o1 = 0;
|
||||
}
|
||||
break;
|
||||
|
|
|
@ -2272,12 +2272,12 @@ vaddr(Link *ctxt, Addr *a, Reloc *r)
|
|||
if(ctxt->flag_shared || ctxt->headtype == Hnacl) {
|
||||
if(s->type == STLSBSS) {
|
||||
r->xadd = r->add - r->siz;
|
||||
r->type = D_TLS;
|
||||
r->type = R_TLS;
|
||||
r->xsym = s;
|
||||
} else
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
} else
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
}
|
||||
return v;
|
||||
}
|
||||
|
@ -3024,7 +3024,7 @@ found:
|
|||
r->off = p->pc + ctxt->andptr - ctxt->and;
|
||||
r->sym = p->to.sym;
|
||||
r->add = p->to.offset;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->siz = 4;
|
||||
put4(ctxt, 0);
|
||||
break;
|
||||
|
@ -3042,7 +3042,7 @@ found:
|
|||
r = addrel(ctxt->cursym);
|
||||
r->off = p->pc + ctxt->andptr - ctxt->and;
|
||||
r->sym = p->to.sym;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->siz = 4;
|
||||
put4(ctxt, 0);
|
||||
break;
|
||||
|
@ -3461,7 +3461,7 @@ asmins(Link *ctxt, Prog *p)
|
|||
break;
|
||||
if(ctxt->rexflag)
|
||||
r->off++;
|
||||
if(r->type == D_PCREL)
|
||||
if(r->type == R_PCREL)
|
||||
r->add -= p->pc + n - (r->off + r->siz);
|
||||
}
|
||||
|
||||
|
|
|
@ -1717,7 +1717,7 @@ vaddr(Link *ctxt, Addr *a, Reloc *r)
|
|||
ctxt->diag("need reloc for %D", a);
|
||||
sysfatal("bad code");
|
||||
}
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->siz = 4;
|
||||
r->off = -1;
|
||||
r->sym = s;
|
||||
|
@ -2360,7 +2360,7 @@ found:
|
|||
*ctxt->andptr++ = op;
|
||||
r = addrel(ctxt->cursym);
|
||||
r->off = p->pc + ctxt->andptr - ctxt->and;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->siz = 4;
|
||||
r->sym = p->to.sym;
|
||||
r->add = p->to.offset;
|
||||
|
@ -2379,7 +2379,7 @@ found:
|
|||
r = addrel(ctxt->cursym);
|
||||
r->off = p->pc + ctxt->andptr - ctxt->and;
|
||||
r->sym = p->to.sym;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->siz = 4;
|
||||
put4(ctxt, 0);
|
||||
break;
|
||||
|
@ -2445,7 +2445,7 @@ found:
|
|||
*ctxt->andptr++ = o->op[z+1];
|
||||
r = addrel(ctxt->cursym);
|
||||
r->off = p->pc + ctxt->andptr - ctxt->and;
|
||||
r->type = D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->siz = 4;
|
||||
r->add = p->to.offset;
|
||||
put4(ctxt, 0);
|
||||
|
@ -2456,7 +2456,7 @@ found:
|
|||
*ctxt->andptr++ = o->op[z+1];
|
||||
r = addrel(ctxt->cursym);
|
||||
r->off = p->pc + ctxt->andptr - ctxt->and;
|
||||
r->type = D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->siz = 4;
|
||||
r->add = p->to.offset;
|
||||
r->sym = p->to.sym;
|
||||
|
|
|
@ -130,15 +130,13 @@ savedata(Link *ctxt, LSym *s, Prog *p, char *pn)
|
|||
s->p[off+i] = cast[inuxi8[i]];
|
||||
break;
|
||||
}
|
||||
} else if(p->to.type == ctxt->arch->D_ADDR || p->to.type == ctxt->arch->D_SIZE) {
|
||||
} else if(p->to.type == ctxt->arch->D_ADDR) {
|
||||
addr:
|
||||
r = addrel(s);
|
||||
r->off = off;
|
||||
r->siz = siz;
|
||||
r->sym = p->to.sym;
|
||||
r->type = p->to.type;
|
||||
if(r->type != ctxt->arch->D_SIZE)
|
||||
r->type = ctxt->arch->D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->add = p->to.offset;
|
||||
} else {
|
||||
ctxt->diag("bad data: %P", p);
|
||||
|
@ -271,7 +269,7 @@ addaddrplus(Link *ctxt, LSym *s, LSym *t, vlong add)
|
|||
r->sym = t;
|
||||
r->off = i;
|
||||
r->siz = ctxt->arch->ptrsize;
|
||||
r->type = ctxt->arch->D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->add = add;
|
||||
return i + r->siz;
|
||||
}
|
||||
|
@ -292,7 +290,7 @@ addpcrelplus(Link *ctxt, LSym *s, LSym *t, vlong add)
|
|||
r->sym = t;
|
||||
r->off = i;
|
||||
r->add = add;
|
||||
r->type = ctxt->arch->D_PCREL;
|
||||
r->type = R_PCREL;
|
||||
r->siz = 4;
|
||||
return i + r->siz;
|
||||
}
|
||||
|
@ -319,7 +317,7 @@ setaddrplus(Link *ctxt, LSym *s, vlong off, LSym *t, vlong add)
|
|||
r->sym = t;
|
||||
r->off = off;
|
||||
r->siz = ctxt->arch->ptrsize;
|
||||
r->type = ctxt->arch->D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->add = add;
|
||||
return off + r->siz;
|
||||
}
|
||||
|
@ -346,7 +344,7 @@ addsize(Link *ctxt, LSym *s, LSym *t)
|
|||
r->sym = t;
|
||||
r->off = i;
|
||||
r->siz = ctxt->arch->ptrsize;
|
||||
r->type = ctxt->arch->D_SIZE;
|
||||
r->type = R_SIZE;
|
||||
return i + r->siz;
|
||||
}
|
||||
|
||||
|
@ -366,7 +364,7 @@ addaddrplus4(Link *ctxt, LSym *s, LSym *t, vlong add)
|
|||
r->sym = t;
|
||||
r->off = i;
|
||||
r->siz = 4;
|
||||
r->type = ctxt->arch->D_ADDR;
|
||||
r->type = R_ADDR;
|
||||
r->add = add;
|
||||
return i + r->siz;
|
||||
}
|
||||
|
|
|
@ -1039,14 +1039,14 @@ LinkArch linkarm = {
|
|||
.regsize = 4,
|
||||
|
||||
.D_ADDR = D_ADDR,
|
||||
.D_AUTO = D_AUTO,
|
||||
.D_BRANCH = D_BRANCH,
|
||||
.D_CONST = D_CONST,
|
||||
.D_EXTERN = D_EXTERN,
|
||||
.D_FCONST = D_FCONST,
|
||||
.D_NONE = D_NONE,
|
||||
.D_PCREL = D_PCREL,
|
||||
.D_PARAM = D_PARAM,
|
||||
.D_SCONST = D_SCONST,
|
||||
.D_SIZE = D_SIZE,
|
||||
.D_STATIC = D_STATIC,
|
||||
|
||||
.ACALL = ABL,
|
||||
|
|
|
@ -1121,14 +1121,14 @@ LinkArch linkamd64 = {
|
|||
.regsize = 8,
|
||||
|
||||
.D_ADDR = D_ADDR,
|
||||
.D_AUTO = D_AUTO,
|
||||
.D_BRANCH = D_BRANCH,
|
||||
.D_CONST = D_CONST,
|
||||
.D_EXTERN = D_EXTERN,
|
||||
.D_FCONST = D_FCONST,
|
||||
.D_NONE = D_NONE,
|
||||
.D_PCREL = D_PCREL,
|
||||
.D_PARAM = D_PARAM,
|
||||
.D_SCONST = D_SCONST,
|
||||
.D_SIZE = D_SIZE,
|
||||
.D_STATIC = D_STATIC,
|
||||
|
||||
.ACALL = ACALL,
|
||||
|
@ -1166,14 +1166,14 @@ LinkArch linkamd64p32 = {
|
|||
.regsize = 8,
|
||||
|
||||
.D_ADDR = D_ADDR,
|
||||
.D_AUTO = D_AUTO,
|
||||
.D_BRANCH = D_BRANCH,
|
||||
.D_CONST = D_CONST,
|
||||
.D_EXTERN = D_EXTERN,
|
||||
.D_FCONST = D_FCONST,
|
||||
.D_NONE = D_NONE,
|
||||
.D_PCREL = D_PCREL,
|
||||
.D_PARAM = D_PARAM,
|
||||
.D_SCONST = D_SCONST,
|
||||
.D_SIZE = D_SIZE,
|
||||
.D_STATIC = D_STATIC,
|
||||
|
||||
.ACALL = ACALL,
|
||||
|
|
|
@ -875,14 +875,14 @@ LinkArch link386 = {
|
|||
.regsize = 4,
|
||||
|
||||
.D_ADDR = D_ADDR,
|
||||
.D_AUTO = D_AUTO,
|
||||
.D_BRANCH = D_BRANCH,
|
||||
.D_CONST = D_CONST,
|
||||
.D_EXTERN = D_EXTERN,
|
||||
.D_FCONST = D_FCONST,
|
||||
.D_NONE = D_NONE,
|
||||
.D_PCREL = D_PCREL,
|
||||
.D_PARAM = D_PARAM,
|
||||
.D_SCONST = D_SCONST,
|
||||
.D_SIZE = D_SIZE,
|
||||
.D_STATIC = D_STATIC,
|
||||
|
||||
.ACALL = ACALL,
|
||||
|
|
|
@ -83,10 +83,7 @@
|
|||
// - nfile [int]
|
||||
// - file [nfile symbol references]
|
||||
//
|
||||
// The file layout is architecture-independent.
|
||||
// The meaning is almost architecture-independent:
|
||||
// the only field with architecture-dependent meaning is the
|
||||
// relocation's type field.
|
||||
// The file layout and meaning of type integers are architecture-independent.
|
||||
//
|
||||
// TODO(rsc): The file format is good for a first pass but needs work.
|
||||
// - There are SymID in the object file that should really just be strings.
|
||||
|
@ -346,7 +343,12 @@ writesym(Link *ctxt, Biobuf *b, LSym *s)
|
|||
for(a = s->autom; a != nil; a = a->link) {
|
||||
wrsym(b, a->asym);
|
||||
wrint(b, a->aoffset);
|
||||
wrint(b, a->type);
|
||||
if(a->type == ctxt->arch->D_AUTO)
|
||||
wrint(b, A_AUTO);
|
||||
else if(a->type == ctxt->arch->D_PARAM)
|
||||
wrint(b, A_PARAM);
|
||||
else
|
||||
sysfatal("%s: invalid local variable type %d", s->name, a->type);
|
||||
wrsym(b, a->gotype);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue