OpenCores
no use no use 1/1 no use no use
gcc-3.2.3
by Unknown on Dec 22, 2003
Not available!
hi!

in case somebody didn't notice it, i've merged
th Haiko's 'unification' patch. So gcc-3.2.3 should be now ok for everybody.

have fun,
p.
gcc-3.2.3
by Unknown on Jan 9, 2004
Not available!
Hi

in case somebody didn't notice it, i've merged
th Haiko's 'unification' patch. So gcc-3.2.3 should be now ok for everybody.
Unfortunately gcc-3.2.3 seems broken. By following basically the steps from the ats script I can successfully build gcc-3.2.3 and uclinux, but simulating the results gives me: Building automata... done, num uncovered: 0/212. Parsing operands data... done. loadcode: filename linux startaddr=0 virtphy_transl=0 Not COFF file format ELF type: 0x0002 ELF machine: 0x8472 ELF version: 0x00000001 ELF sec = 22 Section: .romvec, vaddr: 0xf0000000, paddr: 0xf0000000, offset: 0x00002000, size: 0x00000c14 Section: .text, vaddr: 0xf0002000, paddr: 0xf0002000, offset: 0x00004000, size: 0x0006b8d8 Section: .rodata, vaddr: 0xf006d8d8, paddr: 0xf006d8d8, offset: 0x0006f8d8, size: 0x0000625a Section: .initrd, vaddr: 0xf0073b38, paddr: 0xf0073b38, offset: 0x00075b38, size: 0x00035c00 Section: .data, vaddr: 0x00002000, paddr: 0xf00a9738, offset: 0x000ac000, size: 0x00007428 Section: .ramvec, vaddr: 0x00000000, paddr: 0xf00b0b60, offset: 0x000b4000, size: 0x00000c14 0 WARNING: Keyboard has problems with RX file stream. Resetting PIC. Resetting memory controller. EXCEPTION: write out of memory (8-bit access to 9c221fe8) Doing the same steps with gcc-3.1 the simulation works (as in the ats script) regards, alex -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/ms-tnef Size: 4001 bytes Desc: not available Url : http://www.opencores.org/forums/openrisc/attachments/20040109/0ac9cb26/attachment-0001.bin
gcc-3.2.3
by Unknown on Jan 9, 2004
Not available!
* Alexander Szekely (lexi@gmx.net) wrote:
Hi

>in case somebody didn't notice it, i've merged
>th Haiko's 'unification' patch. So gcc-3.2.3 should be now ok for everybody.


Unfortunately gcc-3.2.3 seems broken.
By following basically the steps from the ats script I can successfully build
gcc-3.2.3 and uclinux, but simulating the results gives me:


can you give some more context. it could be ld or uclinux. (gcc has some
extra sections)

Building automata... done, num uncovered: 0/212.
Parsing operands data... done.
loadcode: filename linux startaddr=0 virtphy_transl=0
Not COFF file format
ELF type: 0x0002
ELF machine: 0x8472
ELF version: 0x00000001
ELF sec = 22
Section: .romvec, vaddr: 0xf0000000, paddr: 0xf0000000, offset: 0x00002000, size: 0x00000c14
Section: .text, vaddr: 0xf0002000, paddr: 0xf0002000, offset: 0x00004000, size: 0x0006b8d8
Section: .rodata, vaddr: 0xf006d8d8, paddr: 0xf006d8d8, offset: 0x0006f8d8, size: 0x0000625a
Section: .initrd, vaddr: 0xf0073b38, paddr: 0xf0073b38, offset: 0x00075b38, size: 0x00035c00
Section: .data, vaddr: 0x00002000, paddr: 0xf00a9738, offset: 0x000ac000, size: 0x00007428
Section: .ramvec, vaddr: 0x00000000, paddr: 0xf00b0b60, offset: 0x000b4000, size: 0x00000c14
0
WARNING: Keyboard has problems with RX file stream.
Resetting PIC.
Resetting memory controller.
EXCEPTION: write out of memory (8-bit access to 9c221fe8)

Doing the same steps with gcc-3.1 the simulation works (as in the ats script)


thanks for the report.

regards,
p.

gcc-3.2.3
by Unknown on Jan 10, 2004
Not available!
Hello!

> Unfortunately gcc-3.2.3 seems broken.
> By following basically the steps from the ats script I can
> successfully build
> gcc-3.2.3 and uclinux, but simulating the results gives me:


can you give some more context. it could be ld or uclinux.
(gcc has some extra sections)


To reproduce the problem just substitude gcc-3.1 with gcc-3.2.3 in the ats
script (cvs checkout and LIBGCC path for uclinux)

Regards, alex


gcc-3.2.3
by Unknown on Jan 10, 2004
Not available!
* Alexander Szekely (lexi@gmx.net) wrote:
Hello!

> Unfortunately gcc-3.2.3 seems broken.
> By following basically the steps from the ats script I can
> successfully build
> gcc-3.2.3 and uclinux, but simulating the results gives me:

>
> can you give some more context. it could be ld or uclinux.
> (gcc has some extra sections)


To reproduce the problem just substitude gcc-3.1 with gcc-3.2.3 in the ats
script (cvs checkout and LIBGCC path for uclinux)


ok, i'll check that when i have time. i've
debugged several gcc bug's which turned out to be actually a linker
problem. i'm in contact with Scott who made a fix to his
tree and published the patches. the problem is that linker
with those patches segfaults and i am not sure if i'm doing something
wrong or there's been a mistake and published patches are not all there is
to it.

if anyone else has tried Scott's patches (published ~a month ago on this
list) i'd love to hear from them if they work for them or not (i get
segfault everytime i try to link with it).

best regards,
p.

gcc-3.2.3
by Unknown on Jan 11, 2004
Not available!
ok, i'll check that when i have time. i've
debugged several gcc bug's which turned out to be actually a linker
problem. i'm in contact with Scott who made a fix to his
tree and published the patches. the problem is that linker
with those patches segfaults and i am not sure if i'm doing something
wrong or there's been a mistake and published patches are not all there is
to it.

if anyone else has tried Scott's patches (published ~a month ago on this
list) i'd love to hear from them if they work for them or not (i get
segfault everytime i try to link with it).


I just tried to apply the patch, and patch failed on 2 hunks. So you
probably compiled some bogus code, Matjaz - no wonder it crashes.

Scott, can you confirm your patch works with the current CVS binutils?
The CVS binutils don't seem to have changed since you posted your patch,
the last significant change seems to be from May '02. Weird.

Heiko


gcc-3.2.3
by Unknown on Jan 12, 2004
Not available!
* Heiko Panther (heiko.panther@web.de) wrote:
>ok, i'll check that when i have time. i've
>debugged several gcc bug's which turned out to be actually a linker
>problem. i'm in contact with Scott who made a fix to his
>tree and published the patches. the problem is that linker
>with those patches segfaults and i am not sure if i'm doing something
>wrong or there's been a mistake and published patches are not all there is
>to it.
>
>if anyone else has tried Scott's patches (published ~a month ago on this
>list) i'd love to hear from them if they work for them or not (i get
>segfault everytime i try to link with it).


I just tried to apply the patch, and patch failed on 2 hunks. So you
probably compiled some bogus code, Matjaz - no wonder it crashes.

Scott, can you confirm your patch works with the current CVS binutils?
The CVS binutils don't seem to have changed since you posted your patch,
the last significant change seems to be from May '02. Weird.


ok, i may have overlooked the failed warning, thinking it was applied with
an offset.

thanks for checking it out Heiko!

regards,
p.

gcc-3.2.3
by Unknown on Jan 13, 2004
Not available!
Skipped content of type multipart/alternative-------------- next part -------------- Index: bfd/elf32-or32.c =================================================================== RCS file: /home/oc/cvs/or1k/binutils/bfd/elf32-or32.c,v retrieving revision 1.11 diff -c -r1.11 elf32-or32.c *** bfd/elf32-or32.c 15 Nov 2003 01:12:01 -0000 1.11 --- bfd/elf32-or32.c 13 Jan 2004 06:03:33 -0000 *************** *** 231,236 **** --- 231,295 ---- cache_ptr->howto = &elf_or32_howto_table[r_type]; } + /* Look through the relocs for a section during the first phase. + Since we don't do .gots or .plts, we just need to consider the + virtual table relocs for gc. */ + + static boolean + or32_elf_check_relocs (abfd, info, sec, relocs) + bfd *abfd; + struct bfd_link_info *info; + asection *sec; + const Elf_Internal_Rela *relocs; + { + Elf_Internal_Shdr *symtab_hdr; + struct elf_link_hash_entry **sym_hashes, **sym_hashes_end; + const Elf_Internal_Rela *rel; + const Elf_Internal_Rela *rel_end; + + if (info->relocateable) + return true; + + symtab_hdr = &elf_tdata (abfd)->symtab_hdr; + sym_hashes = elf_sym_hashes (abfd); + sym_hashes_end = + sym_hashes + symtab_hdr->sh_size / sizeof (Elf32_External_Sym); + if (!elf_bad_symtab (abfd)) + sym_hashes_end -= symtab_hdr->sh_info; + + rel_end = relocs + sec->reloc_count; + for (rel = relocs; rel r_info); + if (r_symndx sh_info) + h = NULL; + else + h = sym_hashes[r_symndx - symtab_hdr->sh_info]; + + switch (ELF32_R_TYPE (rel->r_info)) + { + /* This relocation describes the C++ object vtable hierarchy. + Reconstruct it for later use during GC. */ + case R_OR32_GNU_VTINHERIT: + if (!_bfd_elf32_gc_record_vtinherit (abfd, sec, h, rel->r_offset)) + return false; + break; + + /* This relocation describes which C++ vtable entries are actually + used. Record for later use during GC. */ + case R_OR32_GNU_VTENTRY: + if (!_bfd_elf32_gc_record_vtentry (abfd, sec, h, rel->r_addend)) + return false; + break; + } + } + + return true; + } + /* Set the right machine number for an OR32 ELF file. */ static boolean *************** *** 268,273 **** --- 327,557 ---- elf_elfheader (abfd)->e_flags |= val; } + /* Perform a single relocation. By default we use the standard BFD + routines, but a few relocs, we have to do them ourselves. */ + /* + static bfd_reloc_status_type + or32_final_link_relocate (howto, input_bfd, input_section, contents, rel, + relocation) + reloc_howto_type *howto; + bfd *input_bfd; + asection *input_section; + bfd_byte *contents; + Elf_Internal_Rela *rel; + bfd_vma relocation; + { + bfd_reloc_status_type r = bfd_reloc_ok; + + switch (howto->type) + { + case R_OR32_LO_16_IN_INSN: + relocation &= 0xffff; + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, rel->r_addend); + break; + + default: + r = _bfd_final_link_relocate (howto, input_bfd, input_section, + contents, rel->r_offset, + relocation, rel->r_addend); + } + + return r; + } + */ + /* Relocate an OpenRISC ELF section. + There is some attempt to make this function usable for many architectures, + both USE_REL and USE_RELA ['twould be nice if such a critter existed], + if only to serve as a learning tool. + + The RELOCATE_SECTION function is called by the new ELF backend linker + to handle the relocations for a section. + + The relocs are always passed as Rela structures; if the section + actually uses Rel structures, the r_addend field will always be + zero. + + This function is responsible for adjusting the section contents as + necessary, and (if using Rela relocs and generating a relocateable + output file) adjusting the reloc addend as necessary. + + This function does not have to worry about setting the reloc + address or the reloc symbol index. + + LOCAL_SYMS is a pointer to the swapped in local symbols. + + LOCAL_SECTIONS is an array giving the section in the input file + corresponding to the st_shndx field of each local symbol. + + The global hash table entry for the global symbols can be found + via elf_sym_hashes (input_bfd). + + When generating relocateable output, this function must handle + STB_LOCAL/STT_SECTION symbols specially. The output symbol is + going to be the section symbol corresponding to the output + section, which means that the addend must be adjusted + accordingly. */ + + /* static boolean */ + /* or32_elf_relocate_section (output_bfd, info, input_bfd, input_section, */ + /* contents, relocs, local_syms, local_sections) */ + /* bfd *output_bfd; */ + /* struct bfd_link_info *info; */ + /* bfd *input_bfd; */ + /* asection *input_section; */ + /* bfd_byte *contents; */ + /* Elf_Internal_Rela *relocs; */ + /* Elf_Internal_Sym *local_syms; */ + /* asection **local_sections; */ + /* { */ + /* Elf_Internal_Shdr *symtab_hdr; */ + /* struct elf_link_hash_entry **sym_hashes; */ + /* Elf_Internal_Rela *rel; */ + /* Elf_Internal_Rela *relend; */ + + /* symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr; */ + /* sym_hashes = elf_sym_hashes (input_bfd); */ + /* relend = relocs + input_section->reloc_count; */ + + /* for (rel = relocs; rel r_info); */ + /* r_symndx = ELF32_R_SYM (rel->r_info); */ + + /* if (r_type == R_OR32_GNU_VTINHERIT */ + /* || r_type == R_OR32_GNU_VTENTRY) */ + /* continue; */ + + /* if (info->relocateable) */ + /* { */ + /* /\* This is a relocateable link. We don't have to change */ + /* anything, unless the reloc is against a section symbol, */ + /* in which case we have to adjust according to where the */ + /* section symbol winds up in the output section. *\/ */ + /* if (r_symndx sh_info) */ + /* { */ + /* sym = local_syms + r_symndx; */ + + /* if (ELF_ST_TYPE (sym->st_info) == STT_SECTION) */ + /* { */ + /* sec = local_sections[r_symndx]; */ + /* rel->r_addend += sec->output_offset + sym->st_value; */ + /* } */ + /* } */ + /* continue; */ + /* } */ + + /* if ((unsigned int) r_type > */ + /* (sizeof or32_elf_howto_table / sizeof (reloc_howto_type))) */ + /* abort (); */ + + /* /\* This is a final link. *\/ */ + /* howto = or32_elf_howto_table + ELF32_R_TYPE (rel->r_info); */ + /* h = NULL; */ + /* sym = NULL; */ + /* sec = NULL; */ + + /* if (r_symndx sh_info) */ + /* { */ + /* sym = local_syms + r_symndx; */ + /* sec = local_sections[r_symndx]; */ + /* relocation = _bfd_elf_rela_local_sym (output_bfd, sym, sec, rel); */ + + /* name = bfd_elf_string_from_elf_section */ + /* (input_bfd, symtab_hdr->sh_link, sym->st_name); */ + /* name = (name == NULL) ? bfd_section_name (input_bfd, sec) : name; */ + /* } */ + /* else */ + /* { */ + /* h = sym_hashes[r_symndx - symtab_hdr->sh_info]; */ + + /* while (h->root.type == bfd_link_hash_indirect */ + /* || h->root.type == bfd_link_hash_warning) */ + /* h = (struct elf_link_hash_entry *) h->root.u.i.link; */ + + /* name = h->root.root.string; */ + + /* if (h->root.type == bfd_link_hash_defined */ + /* || h->root.type == bfd_link_hash_defweak) */ + /* { */ + /* sec = h->root.u.def.section; */ + /* relocation = (h->root.u.def.value */ + /* + sec->output_section->vma + sec->output_offset); */ + /* } */ + /* else if (h->root.type == bfd_link_hash_undefweak) */ + /* { */ + /* relocation = 0; */ + /* } */ + /* else */ + /* { */ + /* if (!((*info->callbacks->undefined_symbol) */ + /* (info, h->root.root.string, input_bfd, */ + /* input_section, rel->r_offset, true))) */ + /* return false; */ + /* relocation = 0; */ + /* } */ + /* } */ + + /* r = or32_final_link_relocate (howto, input_bfd, input_section, */ + /* contents, rel, relocation); */ + + /* if (r != bfd_reloc_ok) */ + /* { */ + /* const char *msg = (const char *) NULL; */ + + /* switch (r) */ + /* { */ + /* case bfd_reloc_overflow: */ + /* r = info->callbacks->reloc_overflow */ + /* (info, name, howto->name, (bfd_vma) 0, */ + /* input_bfd, input_section, rel->r_offset); */ + /* break; */ + + /* case bfd_reloc_undefined: */ + /* r = info->callbacks->undefined_symbol */ + /* (info, name, input_bfd, input_section, rel->r_offset, true); */ + /* break; */ + + /* case bfd_reloc_outofrange: */ + /* msg = _("internal error: out of range error"); */ + /* break; */ + + /* case bfd_reloc_notsupported: */ + /* msg = _("internal error: unsupported relocation error"); */ + /* break; */ + + /* case bfd_reloc_dangerous: */ + /* msg = _("internal error: dangerous relocation"); */ + /* break; */ + + /* default: */ + /* msg = _("internal error: unknown error"); */ + /* break; */ + /* } */ + + /* if (msg) */ + /* r = info->callbacks->warning */ + /* (info, msg, name, input_bfd, input_section, rel->r_offset); */ + + /* if (!r) */ + /* return false; */ + /* } */ + /* } */ + + /* return true; */ + /* } */ + bfd_reloc_status_type or32_elf_32_reloc (abfd, reloc_entry, symbol, data, input_section, output_bfd, error_message) *************** *** 377,383 **** { struct or32_consth *next; bfd_byte *addr; ! bfd_vma addend; }; /* FIXME: This should not be a static variable. */ --- 661,667 ---- { struct or32_consth *next; bfd_byte *addr; ! asymbol *symbol; }; /* FIXME: This should not be a static variable. */ *************** *** 395,430 **** bfd *output_bfd; char **error_message ATTRIBUTE_UNUSED; { - bfd_reloc_status_type ret; - bfd_vma relocation; struct or32_consth *n; - - ret = bfd_reloc_ok; ! relocation = symbol->section->output_section->vma; ! relocation += symbol->section->output_offset; ! if (!bfd_is_com_section (symbol->section)) ! relocation += symbol->value; /* Save the information, and let LO16 do the actual relocation. */ n = (struct or32_consth *) bfd_malloc (sizeof *n); if (n == NULL) return bfd_reloc_outofrange; n->addr = (bfd_byte *) data + reloc_entry->address; - n->addend = relocation; n->next = or32_consth_list; or32_consth_list = n; - reloc_entry->addend = 0; ! if (output_bfd != (bfd *) NULL ! && (symbol->flags & BSF_GLOBAL)) ! { ! reloc_entry->address += input_section->output_offset; ! return bfd_reloc_ok; ! } ! else ! return bfd_reloc_continue; } /* Do a R_OR32_CONST relocation. This is a straightforward 16 bit --- 679,710 ---- bfd *output_bfd; char **error_message ATTRIBUTE_UNUSED; { struct or32_consth *n; ! if (output_bfd != (bfd *) NULL ! && !(symbol->flags & BSF_SECTION_SYM)) ! { ! reloc_entry->address += input_section->output_offset; ! return bfd_reloc_ok; ! } ! ! if (bfd_is_und_section (symbol->section) ! && output_bfd == (bfd *) NULL) ! return bfd_reloc_undefined; /* Save the information, and let LO16 do the actual relocation. */ n = (struct or32_consth *) bfd_malloc (sizeof *n); if (n == NULL) return bfd_reloc_outofrange; + /* Push this reloc on the list of pending relocations */ n->addr = (bfd_byte *) data + reloc_entry->address; n->next = or32_consth_list; + n->symbol = symbol; or32_consth_list = n; ! reloc_entry->address += input_section->output_offset; ! return bfd_reloc_ok; } /* Do a R_OR32_CONST relocation. This is a straightforward 16 bit *************** *** 442,447 **** --- 722,763 ---- bfd *output_bfd; char **error_message; { + unsigned long insn_hi, insn_lo; + bfd_reloc_status_type ret; + bfd_size_type insn_lo_addr; + bfd_vma relocation; + unsigned long val; + + if (output_bfd != (bfd *) NULL + && !(symbol->flags & BSF_SECTION_SYM)) + { + reloc_entry->address += input_section->output_offset; + return bfd_reloc_ok; + } + + if (bfd_is_und_section (symbol->section) + && output_bfd == (bfd *) NULL) + return bfd_reloc_undefined; + + relocation = symbol->section->output_section->vma; + relocation += symbol->section->output_offset; + + if (!bfd_is_com_section (symbol->section)) + relocation += symbol->value; + + /* Retrieve the instruction containing the low 16 bits of the offset */ + insn_lo_addr = reloc_entry->address; + reloc_entry->address += input_section->output_offset; + insn_lo = bfd_get_32 (abfd, (bfd_byte *) data + insn_lo_addr); + + /* Add in the relocation and update LO16 the instruction in place */ + relocation += insn_lo & 0xffff; + insn_lo = (insn_lo & 0xffff0000) | (relocation & 0x0000ffff); + bfd_put_32 (abfd, insn_lo, (bfd_byte *) data + insn_lo_addr); + + ret = bfd_reloc_ok; + + /* Iterate over the list of previously encountered HI16 relocations */ if (or32_consth_list != NULL) { struct or32_consth *l; *************** *** 449,480 **** l = or32_consth_list; while (l != NULL) { - unsigned long insn; - unsigned long val; - unsigned long vallo; struct or32_consth *next; /* Do the HI16 relocation. Note that we actually don't need to know anything about the LO16 itself, except where to find the low 16 bits of the addend needed by the LO16. */ ! insn = bfd_get_32 (abfd, l->addr); ! vallo = (bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address) & 0xffff); ! if (output_bfd != (bfd *) NULL ! && !(symbol->flags & BSF_GLOBAL)) ! { ! val = (insn addend; ! insn = (insn &~ 0xffff) | (val >> 16); ! } ! else ! { ! val = vallo + (l->addend & 0xffff); ! val = (insn + (val >> 16)) & 0xffff; ! insn = (insn &~ 0xffff) | val; ! } ! ! bfd_put_32 (abfd, insn, l->addr); next = l->next; free (l); l = next; --- 765,788 ---- l = or32_consth_list; while (l != NULL) { struct or32_consth *next; + if (l->symbol != symbol) { + *error_message = + (char *) _("Symbol for R_OR32_CONSTH reloc doesn't match symbol " + "in following R_OR32_CONST reloc"); + ret = bfd_reloc_dangerous; + } + /* Do the HI16 relocation. Note that we actually don't need to know anything about the LO16 itself, except where to find the low 16 bits of the addend needed by the LO16. */ ! insn_hi = bfd_get_32 (abfd, l->addr); ! val = (insn_hi > 16); ! bfd_put_32 (abfd, insn_hi, l->addr); ! next = l->next; free (l); l = next; *************** *** 483,508 **** or32_consth_list = NULL; } - if (output_bfd != (bfd *) NULL - && !(symbol->flags & BSF_GLOBAL)) - { - unsigned long insn, tmp; - bfd_size_type addr = reloc_entry->address; - insn = bfd_get_32 (abfd, (bfd_byte *) data + addr); - reloc_entry->address += input_section->output_offset; - - tmp = insn & 0x0000ffff; - tmp += symbol->section->output_section->vma; - tmp += symbol->section->output_offset; - if (!bfd_is_com_section (symbol->section)) - tmp += symbol->value; - insn = (insn & 0xffff0000) | (tmp & 0x0000ffff); - bfd_put_32 (abfd, insn, (bfd_byte *) data + addr); ! return bfd_reloc_ok; ! } ! ! return bfd_reloc_continue; } bfd_reloc_status_type --- 791,798 ---- or32_consth_list = NULL; } ! return ret; } bfd_reloc_status_type *************** *** 516,533 **** bfd *output_bfd; char **error_message ATTRIBUTE_UNUSED; { ! if (output_bfd != (bfd *) NULL ! && (symbol->flags & BSF_SECTION_SYM) == 0) { ! unsigned long insn, tmp; bfd_size_type addr = reloc_entry->address; insn = bfd_get_32 (abfd, (bfd_byte *) data + addr); reloc_entry->address += input_section->output_offset; reloc_entry->addend += input_section->output_offset; tmp = insn | 0xfc000000; ! tmp -= (input_section->output_offset) >> 2; insn = (insn & 0xfc000000) | (tmp & 0x03ffffff); bfd_put_32 (abfd, insn, (bfd_byte *) data + addr); --- 806,828 ---- bfd *output_bfd; char **error_message ATTRIBUTE_UNUSED; { ! if (output_bfd != (bfd *) NULL) { ! unsigned long insn, tmp, offset; bfd_size_type addr = reloc_entry->address; insn = bfd_get_32 (abfd, (bfd_byte *) data + addr); reloc_entry->address += input_section->output_offset; reloc_entry->addend += input_section->output_offset; + if (symbol->flags & BSF_SECTION_SYM) + offset = symbol->section->output_offset; + else + offset = 0; + offset -= input_section->output_offset; + tmp = insn | 0xfc000000; ! tmp += offset >> 2; insn = (insn & 0xfc000000) | (tmp & 0x03ffffff); bfd_put_32 (abfd, insn, (bfd_byte *) data + addr); *************** *** 544,553 **** #define TARGET_BIG_NAME "elf32-or32" #define ELF_ARCH bfd_arch_or32 #define ELF_MACHINE_CODE EM_OR32 ! #define ELF_MAXPAGESIZE 0x2000 #define elf_info_to_howto 0 #define elf_info_to_howto_rel or32_info_to_howto_rel #define elf_backend_object_p or32_elf_object_p #define elf_backend_final_write_processing \ or32_elf_final_write_processing --- 839,851 ---- #define TARGET_BIG_NAME "elf32-or32" #define ELF_ARCH bfd_arch_or32 #define ELF_MACHINE_CODE EM_OR32 ! #define ELF_MAXPAGESIZE 0x1000 #define elf_info_to_howto 0 #define elf_info_to_howto_rel or32_info_to_howto_rel + //#define bfd_elf32_bfd_link_hash_table_create _bfd_elf_link_hash_table_create + //#define elf_backend_can_gc_sections 1 + //#define elf_backend_check_relocs or32_elf_check_relocs #define elf_backend_object_p or32_elf_object_p #define elf_backend_final_write_processing \ or32_elf_final_write_processing Index: ld/emulparams/or32elf.sh =================================================================== RCS file: /home/oc/cvs/or1k/binutils/ld/emulparams/or32elf.sh,v retrieving revision 1.2 diff -c -r1.2 or32elf.sh *** ld/emulparams/or32elf.sh 15 Nov 2003 00:55:23 -0000 1.2 --- ld/emulparams/or32elf.sh 13 Jan 2004 06:03:43 -0000 *************** *** 4,6 **** --- 4,7 ---- TARGET_PAGE_SIZE=0x1000000 MAXPAGESIZE=0x2000 ARCH=or32 + EXTRA_EM_FILE=or32elf Index: ld/emultempl/or32elf.em =================================================================== RCS file: ld/emultempl/or32elf.em diff -N ld/emultempl/or32elf.em *** /dev/null 1 Jan 1970 00:00:00 -0000 --- ld/emultempl/or32elf.em 13 Jan 2004 06:03:43 -0000 *************** *** 0 **** --- 1,370 ---- + # This shell script emits a C file. -*- C -*- + # Copyright 2000, 2001 Free Software Foundation, Inc. + # Written by Michael Sokolov msokolov@ivan.Harhan.ORG>, based on armelf.em + # + # This file is part of GLD, the Gnu Linker. + # + # This program is free software; you can redistribute it and/or modify + # it under the terms of the GNU General Public License as published by + # the Free Software Foundation; either version 2 of the License, or + # (at your option) any later version. + # + # This program is distributed in the hope that it will be useful, + # but WITHOUT ANY WARRANTY; without even the implied warranty of + # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + # GNU General Public License for more details. + # + # You should have received a copy of the GNU General Public License + # along with this program; if not, write to the Free Software + # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + + # This file is sourced from elf32.em, and defines some extra routines for or32 + # embedded systems using ELF and for some other systems using or32 ELF. While + # it is sourced from elf32.em for all or32 ELF configurations, here we include + # only the features we want depending on the configuration. + + cat >>e${EMULATION_NAME}.c next) + { + lookup = &u->output_section_statement; + if (strncmp (".rel", lookup->name, 4) == 0 + && lookup->bfd_section != NULL + && (lookup->bfd_section->flags & SEC_ALLOC) != 0) + { + return lookup; + } + } + return (lang_output_section_statement_type *) NULL; + } + + /* Find the last output section before given output statement. + Used by place_orphan. */ + + static asection * + output_prev_sec_find (os) + lang_output_section_statement_type *os; + { + asection *s = (asection *) NULL; + lang_statement_union_type *u; + lang_output_section_statement_type *lookup; + + for (u = lang_output_section_statement.head; + u != (lang_statement_union_type *) NULL; + u = lookup->next) + { + lookup = &u->output_section_statement; + if (lookup == os) + return s; + + if (lookup->bfd_section != NULL && lookup->bfd_section->owner != NULL) + s = lookup->bfd_section; + } + + return NULL; + } + + /* Place an orphan section. We use this to put random SHF_ALLOC + sections in the right segment. */ + + struct orphan_save { + lang_output_section_statement_type *os; + asection **section; + lang_statement_union_type **stmt; + }; + + static boolean + gld${EMULATION_NAME}_place_orphan (file, s) + lang_input_statement_type *file; + asection *s; + { + static struct orphan_save hold_text; + static struct orphan_save hold_rodata; + static struct orphan_save hold_data; + static struct orphan_save hold_bss; + static struct orphan_save hold_rel; + static struct orphan_save hold_interp; + static struct orphan_save hold_sdata; + static int count = 1; + struct orphan_save *place; + lang_statement_list_type *old; + lang_statement_list_type add; + etree_type *address; + const char *secname; + const char *outsecname; + const char *ps = NULL; + lang_output_section_statement_type *os; + + secname = bfd_get_section_name (s->owner, s); + + if (! config.unique_orphan_sections && ! unique_section_p (secname)) + { + /* Look through the script to see where to place this section. */ + os = lang_output_section_find (secname); + + if (os != NULL + && (os->bfd_section == NULL + || ((s->flags ^ os->bfd_section->flags) + & (SEC_LOAD | SEC_ALLOC)) == 0)) + { + /* We already have an output section statement with this + name, and its bfd section, if any, has compatible flags. */ + lang_add_section (&os->children, s, os, file); + return true; + } + } + + if (hold_text.os == NULL) + hold_text.os = lang_output_section_find (".text"); + + /* If this is a final link, then always put .gnu.warning.SYMBOL + sections into the .text section to get them out of the way. */ + if (! link_info.shared + && ! link_info.relocateable + && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0 + && hold_text.os != NULL) + { + lang_add_section (&hold_text.os->children, s, hold_text.os, file); + return true; + } + + /* Decide which segment the section should go in based on the + section name and section flags. We put loadable .note sections + right after the .interp section, so that the PT_NOTE segment is + stored right after the program headers where the OS can read it + in the first page. */ + #define HAVE_SECTION(hold, name) \ + (hold.os != NULL || (hold.os = lang_output_section_find (name)) != NULL) + + if (s->flags & SEC_EXCLUDE) + { + if (s->output_section == NULL) + s->output_section = bfd_abs_section_ptr; + return true; + } + + place = NULL; + if ((s->flags & SEC_ALLOC) == 0) + ; + else if ((s->flags & SEC_LOAD) != 0 + && strncmp (secname, ".note", 5) == 0 + && HAVE_SECTION (hold_interp, ".interp")) + place = &hold_interp; + else if ((s->flags & SEC_HAS_CONTENTS) == 0 + && HAVE_SECTION (hold_bss, ".bss")) + place = &hold_bss; + else if ((s->flags & SEC_SMALL_DATA) != 0 + && HAVE_SECTION (hold_sdata, ".sdata")) + place = &hold_sdata; + else if ((s->flags & SEC_READONLY) == 0 + && HAVE_SECTION (hold_data, ".data")) + place = &hold_data; + else if (strncmp (secname, ".rel", 4) == 0 + && (hold_rel.os != NULL + || (hold_rel.os = output_rel_find ()) != NULL)) + { + if (! link_info.relocateable && link_info.combreloc) + { + if (strncmp (secname, ".rela", 5) == 0) + os = lang_output_section_find (".rela.dyn"); + else + os = lang_output_section_find (".rel.dyn"); + + if (os != NULL + && os->bfd_section != NULL + && ((s->flags ^ os->bfd_section->flags) + & (SEC_LOAD | SEC_ALLOC)) == 0) + { + lang_add_section (&os->children, s, os, file); + return true; + } + } + place = &hold_rel; + } + else if ((s->flags & (SEC_CODE | SEC_READONLY)) == SEC_READONLY + && HAVE_SECTION (hold_rodata, ".rodata")) + place = &hold_rodata; + else if ((s->flags & (SEC_CODE | SEC_READONLY)) == (SEC_CODE | SEC_READONLY) + && hold_text.os != NULL) + place = &hold_text; + + #undef HAVE_SECTION + + /* Choose a unique name for the section. This will be needed if the + same section name appears in the input file with different + loadable or allocatable characteristics. */ + outsecname = secname; + if (bfd_get_section_by_name (output_bfd, outsecname) != NULL) + { + outsecname = bfd_get_unique_section_name (output_bfd, + outsecname, + &count); + if (outsecname == NULL) + einfo ("%F%P: place_orphan failed: %E\n"); + } + + /* Start building a list of statements for this section. + First save the current statement pointer. */ + old = stat_ptr; + + /* If we have found an appropriate place for the output section + statements for this orphan, add them to our own private list, + inserting them later into the global statement list. */ + if (place != NULL) + { + stat_ptr = &add; + lang_list_init (stat_ptr); + } + + if (config.build_constructors) + { + /* If the name of the section is representable in C, then create + symbols to mark the start and the end of the section. */ + for (ps = outsecname; *ps != ''; ps++) + if (! ISALNUM (*ps) && *ps != '_') + break; + if (*ps == '') + { + char *symname; + etree_type *e_align; + + symname = (char *) xmalloc (ps - outsecname + sizeof "__start_"); + sprintf (symname, "__start_%s", outsecname); + e_align = exp_unop (ALIGN_K, + exp_intop ((bfd_vma) 1 alignment_power)); + lang_add_assignment (exp_assop ('=', symname, e_align)); + } + } + + if (link_info.relocateable || (s->flags & (SEC_LOAD | SEC_ALLOC)) == 0) + address = exp_intop ((bfd_vma) 0); + else + address = NULL; + + os = lang_enter_output_section_statement (outsecname, address, 0, + (bfd_vma) 0, + (etree_type *) NULL, + (etree_type *) NULL, + (etree_type *) NULL); + + lang_add_section (&os->children, s, os, file); + + lang_leave_output_section_statement + ((bfd_vma) 0, "*default*", + (struct lang_output_section_phdr_list *) NULL, "*default*"); + + if (config.build_constructors && *ps == '') + { + char *symname; + + /* lang_leave_ouput_section_statement resets stat_ptr. Put + stat_ptr back where we want it. */ + if (place != NULL) + stat_ptr = &add; + + symname = (char *) xmalloc (ps - outsecname + sizeof "__stop_"); + sprintf (symname, "__stop_%s", outsecname); + lang_add_assignment (exp_assop ('=', symname, + exp_nameop (NAME, "."))); + } + + /* Restore the global list pointer. */ + stat_ptr = old; + + if (place != NULL) + { + asection *snew, **pps; + + snew = os->bfd_section; + + /* Shuffle the bfd section list to make the output file look + neater. This is really only cosmetic. */ + if (place->section == NULL) + { + asection *bfd_section = place->os->bfd_section; + + /* If the output statement hasn't been used to place + any input sections (and thus doesn't have an output + bfd_section), look for the closest prior output statement + having an output section. */ + if (bfd_section == NULL) + bfd_section = output_prev_sec_find (place->os); + + if (bfd_section != NULL && bfd_section != snew) + place->section = &bfd_section->next; + } + + if (place->section != NULL) + { + /* Unlink the section. */ + for (pps = &output_bfd->sections; *pps != snew; pps = &(*pps)->next) + ; + bfd_section_list_remove (output_bfd, pps); + + /* Now tack it on to the "place->os" section list. */ + bfd_section_list_insert (output_bfd, place->section, snew); + } + + /* Save the end of this list. Further ophans of this type will + follow the one we've just added. */ + place->section = &snew->next; + + /* The following is non-cosmetic. We try to put the output + statements in some sort of reasonable order here, because + they determine the final load addresses of the orphan + sections. In addition, placing output statements in the + wrong order may require extra segments. For instance, + given a typical situation of all read-only sections placed + in one segment and following that a segment containing all + the read-write sections, we wouldn't want to place an orphan + read/write section before or amongst the read-only ones. */ + if (add.head != NULL) + { + if (place->stmt == NULL) + { + /* Put the new statement list right at the head. */ + *add.tail = place->os->header.next; + place->os->header.next = add.head; + } + else + { + /* Put it after the last orphan statement we added. */ + *add.tail = *place->stmt; + *place->stmt = add.head; + } + + /* Fix the global list pointer if we happened to tack our + new list at the tail. */ + if (*old->tail == add.head) + old->tail = add.tail; + + /* Save the end of this list. */ + place->stmt = add.tail; + } + } + + return true; + } + EOF + + LDEMUL_PLACE_ORPHAN=gld${EMULATION_NAME}_place_orphan
no use no use 1/1 no use no use
© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.