Clang-format before editing.

This commit is contained in:
David Given 2018-09-14 09:28:35 +02:00
parent c4e3d0903e
commit ac33bdd031

View file

@ -34,10 +34,13 @@ static uint32_t read4(char* addr, int type)
{
unsigned short word0, word1;
if (type & RELBR) {
if (type & RELBR)
{
word0 = (UBYTE(addr[0]) << WIDTH) + UBYTE(addr[1]);
word1 = (UBYTE(addr[2]) << WIDTH) + UBYTE(addr[3]);
} else {
}
else
{
word0 = (UBYTE(addr[1]) << WIDTH) + UBYTE(addr[0]);
word1 = (UBYTE(addr[3]) << WIDTH) + UBYTE(addr[2]);
}
@ -145,14 +148,12 @@ static uint32_t get_powerpc_valu(char* addr, uint16_t type)
/* branch instruction */
return opcode1 & 0x03fffffd;
}
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
((opcode2 & 0xfc000000) == 0x60000000))
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) && ((opcode2 & 0xfc000000) == 0x60000000))
{
/* addis / ori instruction pair */
return ((opcode1 & 0xffff) << 16) | (opcode2 & 0xffff);
}
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
is_powerpc_memory_op(opcode2))
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) && is_powerpc_memory_op(opcode2))
{
/* addis / memoryop instruction pair */
uint16_t hi = opcode1 & 0xffff;
@ -166,7 +167,8 @@ static uint32_t get_powerpc_valu(char* addr, uint16_t type)
return ((hi << 16) | lo);
}
fatal("Don't know how to read from PowerPC fixup on instructions 0x%08lx+0x%08lx",
fatal(
"Don't know how to read from PowerPC fixup on instructions 0x%08lx+0x%08lx",
(unsigned long)opcode1, (unsigned long)opcode2);
}
@ -209,7 +211,8 @@ static uint32_t get_mips_valu(char* addr)
*/
static uint32_t getvalu(char* addr, uint16_t type)
{
switch (type & RELSZ) {
switch (type & RELSZ)
{
case RELO1:
return UBYTE(addr[0]);
case RELO2:
@ -236,10 +239,13 @@ static void write2(uint16_t valu, char* addr, int type)
{
unsigned short word0, word1;
if (type & RELBR) {
if (type & RELBR)
{
addr[0] = valu >> WIDTH;
addr[1] = valu;
} else {
}
else
{
addr[0] = valu;
addr[1] = valu >> WIDTH;
}
@ -249,19 +255,25 @@ static void write4(uint32_t valu, char* addr, int type)
{
unsigned short word0, word1;
if (type & RELWR) {
if (type & RELWR)
{
word0 = valu >> (2 * WIDTH);
word1 = valu;
} else {
}
else
{
word0 = valu;
word1 = valu >> (2 * WIDTH);
}
if (type & RELBR) {
if (type & RELBR)
{
addr[0] = word0 >> WIDTH;
addr[1] = word0;
addr[2] = word1 >> WIDTH;
addr[3] = word1;
} else {
}
else
{
addr[0] = word0;
addr[1] = word0 >> WIDTH;
addr[2] = word1;
@ -340,8 +352,7 @@ static void put_powerpc_valu(char* addr, uint32_t value, uint16_t type)
i |= value & 0x03fffffd;
write4(i, addr, type);
}
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
((opcode2 & 0xfc000000) == 0x60000000))
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) && ((opcode2 & 0xfc000000) == 0x60000000))
{
/* addis / ori instruction pair */
uint16_t hi = value >> 16;
@ -350,8 +361,7 @@ static void put_powerpc_valu(char* addr, uint32_t value, uint16_t type)
write4((opcode1 & 0xffff0000) | hi, addr + 0, type);
write4((opcode2 & 0xffff0000) | lo, addr + 4, type);
}
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) &&
is_powerpc_memory_op(opcode2))
else if (((opcode1 & 0xfc1f0000) == 0x3c000000) && is_powerpc_memory_op(opcode2))
{
/* addis / memoryop instruction pair */
uint16_t hi = value >> 16;
@ -367,7 +377,8 @@ static void put_powerpc_valu(char* addr, uint32_t value, uint16_t type)
}
else
fatal("Don't know how to write a PowerPC fixup to instructions 0x%08lx+0x%08lx",
fatal(
"Don't know how to write a PowerPC fixup to instructions 0x%08lx+0x%08lx",
(unsigned long)opcode1, (unsigned long)opcode2);
}
@ -435,7 +446,8 @@ static void put_mips_valu(char* addr, uint32_t value)
static putvalu(uint32_t valu, char* addr, uint16_t type)
{
switch (type & RELSZ) {
switch (type & RELSZ)
{
case RELO1:
addr[0] = valu;
break;
@ -483,9 +495,7 @@ extern struct orig relorig[];
* Second case: we must update the value by the change
* in position of the section of local.
*/
static unsigned
addrelo(relo, names, valu_out)
struct outrelo *relo;
static unsigned addrelo(relo, names, valu_out) struct outrelo* relo;
struct outname* names;
long* valu_out; /* Out variable. */
{
@ -493,13 +503,16 @@ addrelo(relo, names, valu_out)
register unsigned short index = NLocals;
register long valu = *valu_out;
if ((local->on_type & S_SCT)) {
if ((local->on_type & S_SCT))
{
register int sectindex = (local->on_type & S_TYP) - S_MIN;
valu += relorig[sectindex].org_size;
valu += outsect[sectindex].os_base;
index += NGlobals + sectindex;
} else {
}
else
{
register struct outname* name;
extern int hash();
extern struct outname* searchname();
@ -509,16 +522,20 @@ addrelo(relo, names, valu_out)
name = searchname(local->on_mptr, hash(local->on_mptr));
if (name == (struct outname*)0)
fatal("name %s not found in pass 2", local->on_mptr);
if (ISCOMMON(name) || ISUNDEFINED(name)) {
if (ISCOMMON(name) || ISUNDEFINED(name))
{
debug("can't relocate from %s\n", local->on_mptr, 0, 0, 0);
index += indexof(name);
} else {
}
else
{
valu += name->on_valu;
if ((name->on_type & S_TYP) == S_ABS) {
if ((name->on_type & S_TYP) == S_ABS)
{
index += NGlobals + outhead.oh_nsect;
}
else index += NGlobals +
(name->on_type & S_TYP) - S_MIN;
else
index += NGlobals + (name->on_type & S_TYP) - S_MIN;
}
}
*valu_out = valu;
@ -530,8 +547,7 @@ addrelo(relo, names, valu_out)
* which the header is pointed to by `head'. Relocation is relative to the
* names in `names'; `relo' tells how to relocate.
*/
relocate(head, emit, names, relo, off)
struct outhead *head;
relocate(head, emit, names, relo, off) struct outhead* head;
char* emit;
struct outname names[];
struct outrelo* relo;
@ -553,10 +569,13 @@ relocate(head, emit, names, relo, off)
* - a section name
* - the first name outside! the name table (argh)
*/
if (relo->or_nami < head->oh_nname) {
if (relo->or_nami < head->oh_nname)
{
/* First two cases. */
relo->or_nami = addrelo(relo, names, &valu);
} else {
}
else
{
/*
* Third case: it is absolute. The relocation of absolute
* names is always 0. We only need to change the index.