the generic linker hash table, not the COFF backend linker hash
table! We use this to attach additional data structures we
need while linking on the h8300. */
-struct h8300_coff_link_hash_table
-{
+struct h8300_coff_link_hash_table {
/* The main hash table. */
struct generic_link_hash_table root;
/* Call the allocation method of the superclass. */
ret = ((struct funcvec_hash_entry *)
- bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
+ bfd_hash_newfunc ((struct bfd_hash_entry *) ret, gen_table, string));
if (ret == NULL)
return NULL;
struct funcvec_hash_table *table;
bfd *abfd;
struct bfd_hash_entry *(*newfunc) PARAMS ((struct bfd_hash_entry *,
- struct bfd_hash_table *,
- const char *));
+ struct bfd_hash_table *,
+ const char *));
{
/* Initialize our local fields, then call the generic initialization
routine. */
return bfd_reloc_ok;
}
-static reloc_howto_type howto_table[] =
-{
+static reloc_howto_type howto_table[] = {
HOWTO (R_RELBYTE, 0, 0, 8, false, 0, complain_overflow_bitfield, special, "8", false, 0x000000ff, 0x000000ff, false),
HOWTO (R_RELWORD, 0, 1, 16, false, 0, complain_overflow_bitfield, special, "16", false, 0x0000ffff, 0x0000ffff, false),
HOWTO (R_RELLONG, 0, 2, 32, false, 0, complain_overflow_bitfield, special, "32", false, 0xffffffff, 0xffffffff, false),
/* Turn a howto into a reloc number. */
#define SELECT_RELOC(x,howto) \
- { x.r_type = select_reloc(howto); }
+ { x.r_type = select_reloc (howto); }
-#define BADMAG(x) (H8300BADMAG(x) && H8300HBADMAG(x) && H8300SBADMAG(x))
+#define BADMAG(x) (H8300BADMAG (x) && H8300HBADMAG (x) && H8300SBADMAG (x))
#define H8300 1 /* Customize coffcode.h */
#define __A_MAGIC_SET__
}
}
-#define RTYPE2HOWTO(internal, relocentry) rtype2howto(internal,relocentry)
+#define RTYPE2HOWTO(internal, relocentry) rtype2howto (internal, relocentry)
/* Perform any necessary magic to the addend in a reloc entry. */
#define CALC_ADDEND(abfd, symbol, ext_reloc, cache_ptr) \
- cache_ptr->addend = ext_reloc.r_offset;
+ cache_ptr->addend = ext_reloc.r_offset;
#define RELOC_PROCESSING(relent,reloc,symbols,abfd,section) \
- reloc_processing(relent, reloc, symbols, abfd, section)
+ reloc_processing (relent, reloc, symbols, abfd, section)
static void
reloc_processing (relent, reloc, symbols, abfd, section)
/* If the distance is within -128..+128 inclusive, then we can relax
this jump. +128 is valid since the target will move two bytes
closer if we do relax this branch. */
- if ((int)gap >= -128 && (int)gap <= 128 )
+ if ((int) gap >= -128 && (int) gap <= 128)
{
/* It's possible we may be able to eliminate this branch entirely;
if the previous instruction is a branch around this instruction,
/* If the distance is within -128..+128 inclusive, then we can relax
this jump. +128 is valid since the target will move two bytes
closer if we do relax this branch. */
- if ((int)gap >= -128 && (int)gap <= 128 )
+ if ((int) gap >= -128 && (int) gap <= 128)
{
/* Change the reloc type. */
reloc->howto = howto_table + 15;
/* Sanity check. */
if (value <= 0xff
|| (value >= 0x0000ff00 && value <= 0x0000ffff)
- || (value >= 0x00ffff00 && value <= 0x00ffffff)
+ || (value >= 0x00ffff00 && value <= 0x00ffffff)
|| (value >= 0xffffff00 && value <= 0xffffffff))
{
/* Everything looks OK. Apply the relocation and update the
/* Fix the opcode. For all the move insns, we simply
need to turn off bit 0x20 in the previous byte. */
- data[dst_address - 1] &= ~0x20;
+ data[dst_address - 1] &= ~0x20;
dst_address += 2;
src_address += 4;
}
reloc->howto->name, reloc->addend, input_section->owner,
input_section, reloc->address)))
abort ();
- }
+ }
break;
/* A 16bit absolute branch that is now an 8-bit pc-relative branch. */
abort ();
}
- /* Output the target. */
- bfd_put_8 (abfd, gap, data + dst_address - 1);
+ /* Output the target. */
+ bfd_put_8 (abfd, gap, data + dst_address - 1);
- /* We don't advance dst_address -- the 8bit reloc is applied at
- dst_address - 1, so the next insn should begin at dst_address. */
- src_address += 2;
+ /* We don't advance dst_address -- the 8bit reloc is applied at
+ dst_address - 1, so the next insn should begin at dst_address. */
+ src_address += 2;
- break;
+ break;
/* Similarly for a 24bit absolute that is now 8 bits. */
case R_JMPL2:
/* This does not include any relocation information, but should be
good enough for GDB or objdump to read the file. */
-static reloc_howto_type h8_elf_howto_table[] =
-{
+static reloc_howto_type h8_elf_howto_table[] = {
#define R_H8_NONE_X 0
HOWTO (R_H8_NONE, /* type */
0, /* rightshift */
/* This structure is used to map BFD reloc codes to H8 ELF relocs. */
-struct elf_reloc_map
-{
+struct elf_reloc_map {
bfd_reloc_code_real_type bfd_reloc_val;
unsigned char howto_index;
};
/* An array mapping BFD reloc codes to SH ELF relocs. */
-static const struct elf_reloc_map h8_reloc_map[] =
-{
+static const struct elf_reloc_map h8_reloc_map[] = {
{ BFD_RELOC_NONE, R_H8_NONE_X },
{ BFD_RELOC_32, R_H8_DIR32_X },
{ BFD_RELOC_16, R_H8_DIR16_X },
r = ELF32_R_TYPE (elf_reloc->r_info);
for (i = 0; i < sizeof (h8_elf_howto_table) / sizeof (reloc_howto_type); i++)
- if (h8_elf_howto_table[i].type== r)
+ if (h8_elf_howto_table[i].type == r)
{
bfd_reloc->howto = &h8_elf_howto_table[i];
return;
= ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
ELF32_R_TYPE (R_H8_NONE));
- last_reloc->r_info
+ last_reloc->r_info
= ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
- ELF32_R_TYPE (R_H8_PCREL8));
- last_reloc->r_addend = irel->r_addend;
-
+ ELF32_R_TYPE (R_H8_PCREL8));
+ last_reloc->r_addend = irel->r_addend;
code = bfd_get_8 (abfd,
contents + last_reloc->r_offset - 1);
/* If the distance is within -126..+130 inclusive, then we can
relax this jump. +130 is valid since the target will move
two bytes closer if we do relax this branch. */
- if ((int)gap >= -126 && (int)gap <= 130)
+ if ((int) gap >= -126 && (int) gap <= 130)
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
if (code == 0x58)
{
abort ();
/* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_PCREL8);
- irel->r_offset--;
+ irel->r_offset--;
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec,
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec,
irel->r_offset + 1, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
break;
}
bfd_vma value = symval + irel->r_addend;
if ((bfd_get_mach (abfd) == bfd_mach_h8300
- && value >= 0xff00
- && value <= 0xffff)
- || ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ && value >= 0xff00
+ && value <= 0xffff)
+ || ((bfd_get_mach (abfd) == bfd_mach_h8300h
|| bfd_get_mach (abfd) == bfd_mach_h8300s)
&& value >= 0xffff00
&& value <= 0xffffff))
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
- /* Sanity check. */
- if (code != 0x6a)
+ /* Sanity check. */
+ if (code != 0x6a)
abort ();
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
- if ((code & 0xf0) == 0x00)
+ if ((code & 0xf0) == 0x00)
bfd_put_8 (abfd,
(code & 0xf) | 0x20,
- contents + irel->r_offset - 2);
- else if ((code & 0xf0) == 0x80)
+ contents + irel->r_offset - 2);
+ else if ((code & 0xf0) == 0x80)
bfd_put_8 (abfd,
(code & 0xf) | 0x30,
- contents + irel->r_offset - 2);
- else
+ contents + irel->r_offset - 2);
+ else
abort ();
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_DIR8);
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec,
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec,
irel->r_offset + 1, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
break;
}
bfd_vma value = symval + irel->r_addend;
if ((bfd_get_mach (abfd) == bfd_mach_h8300
- && value >= 0xff00
- && value <= 0xffff)
- || ((bfd_get_mach (abfd) == bfd_mach_h8300h
+ && value >= 0xff00
+ && value <= 0xffff)
+ || ((bfd_get_mach (abfd) == bfd_mach_h8300h
|| bfd_get_mach (abfd) == bfd_mach_h8300s)
&& value >= 0xffff00
&& value <= 0xffffff))
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 2);
- /* Sanity check. */
- if (code != 0x6a)
+ /* Sanity check. */
+ if (code != 0x6a)
abort ();
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
- if ((code & 0xf0) == 0x00)
+ if ((code & 0xf0) == 0x00)
bfd_put_8 (abfd,
(code & 0xf) | 0x20,
- contents + irel->r_offset - 2);
- else if ((code & 0xf0) == 0x80)
+ contents + irel->r_offset - 2);
+ else if ((code & 0xf0) == 0x80)
bfd_put_8 (abfd,
(code & 0xf) | 0x30,
- contents + irel->r_offset - 2);
- else
+ contents + irel->r_offset - 2);
+ else
abort ();
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_DIR8);
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec, irel->r_offset, 2))
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec, irel->r_offset, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
}
if (value <= 0x7fff || value >= 0xff8000)
{
- unsigned char code;
+ unsigned char code;
- /* Note that we've changed the relocs, section contents,
+ /* Note that we've changed the relocs, section contents,
etc. */
- elf_section_data (sec)->relocs = internal_relocs;
- elf_section_data (sec)->this_hdr.contents = contents;
+ elf_section_data (sec)->relocs = internal_relocs;
+ elf_section_data (sec)->this_hdr.contents = contents;
symtab_hdr->contents = (unsigned char *) isymbuf;
- /* Get the opcode. */
- code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
+ /* Get the opcode. */
+ code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
- /* We just need to turn off bit 0x20. */
- code &= ~0x20;
+ /* We just need to turn off bit 0x20. */
+ code &= ~0x20;
- bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
+ bfd_put_8 (abfd, code, contents + irel->r_offset - 1);
- /* Fix the relocation's type. */
- irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
+ /* Fix the relocation's type. */
+ irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),
R_H8_DIR16A8);
- /* Delete two bytes of data. */
- if (!elf32_h8_relax_delete_bytes (abfd, sec,
+ /* Delete two bytes of data. */
+ if (!elf32_h8_relax_delete_bytes (abfd, sec,
irel->r_offset + 1, 2))
goto error_return;
- /* That will change things, so, we should relax again.
+ /* That will change things, so, we should relax again.
Note that this is not required, and it may be slow. */
- *again = true;
+ *again = true;
}
break;
}
shrinks = (unsigned *) bfd_zmalloc (amt);
/* Loop until nothing changes in this section. */
- do {
- arelent **parent;
- unsigned int i;
- long j;
-
- another_pass = 0;
-
- for (i = 0, parent = reloc_vector; *parent; parent++, i++)
- {
- /* Let the target/machine dependent code examine each reloc
- in this section and attempt to shrink it. */
- shrink = bfd_coff_reloc16_estimate (abfd, input_section, *parent,
- shrinks[i], link_info);
-
- /* If it shrunk, note it in the shrinks array and set up for
- another pass. */
- if (shrink != shrinks[i])
- {
- another_pass = 1;
- for (j = i + 1; j <= reloc_count; j++)
- shrinks[j] += shrink - shrinks[i];
- }
- }
- }
+ do
+ {
+ arelent **parent;
+ unsigned int i;
+ long j;
+
+ another_pass = 0;
+
+ for (i = 0, parent = reloc_vector; *parent; parent++, i++)
+ {
+ /* Let the target/machine dependent code examine each reloc
+ in this section and attempt to shrink it. */
+ shrink = bfd_coff_reloc16_estimate (abfd, input_section, *parent,
+ shrinks[i], link_info);
+
+ /* If it shrunk, note it in the shrinks array and set up for
+ another pass. */
+ if (shrink != shrinks[i])
+ {
+ another_pass = 1;
+ for (j = i + 1; j <= reloc_count; j++)
+ shrinks[j] += shrink - shrinks[i];
+ }
+ }
+ }
while (another_pass);
shrink = shrinks[reloc_count];
}
bfd_byte *
-bfd_coff_reloc16_get_relocated_section_contents(in_abfd,
- link_info,
- link_order,
- data,
- relocateable,
- symbols)
+bfd_coff_reloc16_get_relocated_section_contents (in_abfd,
+ link_info,
+ link_order,
+ data,
+ relocateable,
+ symbols)
bfd *in_abfd;
struct bfd_link_info *link_info;
struct bfd_link_order *link_order;
symbols);
/* Read in the section. */
- if (!bfd_get_section_contents(input_bfd,
- input_section,
- data,
- (bfd_vma) 0,
- input_section->_raw_size))
+ if (!bfd_get_section_contents (input_bfd,
+ input_section,
+ data,
+ (bfd_vma) 0,
+ input_section->_raw_size))
return NULL;
reloc_vector = (arelent **) bfd_malloc ((bfd_size_type) reloc_size);