Index: bfd-in2.h =================================================================== RCS file: /cvs/src/src/bfd/bfd-in2.h,v retrieving revision 1.219 diff -r1.219 bfd-in2.h 2393a2394 > BFD_RELOC_MIPS_QNX_COPY, Index: config.bfd =================================================================== RCS file: /cvs/src/src/bfd/config.bfd,v retrieving revision 1.135 diff -r1.135 config.bfd 767a768,782 > mips*eb-*-nto*) > targ_defvec=bfd_elf32_bigmips_vec > targ_selvecs="bfd_elf32_littlemips_vec" > targ_cflags=-D__QNXTARGET__ > ;; > mips*el-*-nto*) > targ_defvec=bfd_elf32_littlemips_vec > targ_selvecs="bfd_elf32_bigmips_vec" > targ_cflags=-D__QNXTARGET__ > ;; > mips*-*-nto*) > targ_defvec=bfd_elf32_littlemips_vec > targ_selvecs="bfd_elf32_bigmips_vec" > targ_cflags=-D__QNXTARGET__ > ;; Index: elf32-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elf32-mips.c,v retrieving revision 1.166 diff -r1.166 elf32-mips.c 605a606,626 > /* Do a QNX pic copy relocation. This is used only with dynamic linking. > This works in the same way as copy relocs on other platforms: the data > object must exist both in the object and in the shared lib. The dynamic > linker copies the data from the shared object to the executable at runtime. > This is needed because the exec. does not access the data through the GOT. > */ > static reloc_howto_type elf_mips_qnx_copy_howto = > HOWTO (R_MIPS_QNX_COPY, /* type */ > 0, /* rightshift */ > 2, /* size (0 = byte, 1 = short, 2 = long) */ > 32, /* bitsize */ > FALSE, /* pc_relative */ > 0, /* bitpos */ > complain_overflow_bitfield, /* complain_on_overflow */ > bfd_elf_generic_reloc, /* special_function */ > "R_MIPS_QNX_COPY", /* name */ > FALSE, /* partial_inplace */ > 0, /* src_mask */ > 0, /* dst_mask */ > FALSE); /* pcrel_offset */ > 970a992,998 > if (output_bfd != (bfd *) NULL > && (symbol->flags & BSF_GLOBAL)) > { > reloc_entry->address += input_section->output_offset; > // reloc_entry->addend = 0; > return bfd_reloc_ok; > } 1408c1436,1437 < { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP } --- > { BFD_RELOC_MIPS_GOT_DISP, R_MIPS_GOT_DISP }, > { BFD_RELOC_MIPS_QNX_COPY, R_MIPS_QNX_COPY } 1855a1885 > #if !defined (__QNXNTO__) && !defined (__QNXTARGET__) 1856a1887 > #endif Index: elfxx-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elfxx-mips.c,v retrieving revision 1.57 diff -r1.57 elfxx-mips.c 615a616,623 > /* Stubs for QNX pic function calls. Allow calling a lib from non-pic code */ > #define STUB_QNX_LW(abfd) \ > (SGI_COMPAT (abfd) \ > ? 0x8f998010 /* lw at,0x8010(gp) */ \ > : 0x8f998000) /* lw at,0x0000(gp) */ > #define STUB_QNX_NOP 0x00000000 > #define STUB_QNX_JR 0x03200008 /* jal t9 */ > 2092a2101,2105 > /* Note the index of the first global got symbol in .dynsym. */ > if (g->global_gotsym == NULL > || g->global_gotsym->dynindx > h->dynindx) > g->global_gotsym = h; > 3321c3334 < & ELF_LINK_HASH_DEF_REGULAR) == 0))) --- > & (ELF_LINK_HASH_DEF_REGULAR|ELF_LINK_HASH_NEEDS_COPY)) == 0))) 5038a5052,5096 > /* QNX - The .rel.bss section holds copy relocs. This section is not > normally needed. We need to create it here, though, so that the > linker will map it to an output section. We can't just create it > only if we need it, because we will not know whether we need it > until we have seen all the input files, and the first time the > main linker code calls BFD after examining all the input files > (size_dynamic_sections) the input sections have already been > mapped to the output sections. If the section turns out not to > be needed, we can discard it later. We will never need this > section when generating a shared object, since they do not use > copy relocs. */ > if (! info->shared) > { > s = bfd_make_section (abfd, ".rel.bss"); > > if (s == NULL > || ! bfd_set_section_flags (abfd, s, flags | SEC_READONLY) > || ! bfd_set_section_alignment (abfd, s, 3)) > return FALSE; > } > > /* We also make a .bss and .sbss section here. This is needed in > case we have copy relocs, but didn't have a bss section in > from the normal symbols. */ > > if ((! info->shared) > && bfd_get_section_by_name (abfd, ".bss") == NULL) > { > s = bfd_make_section (abfd, ".bss"); > if (s == NULL > || ! bfd_set_section_flags (abfd, s, SEC_RELOC | SEC_ALLOC | SEC_HAS_CONTENTS) > || ! bfd_set_section_alignment (abfd, s, 3)) > return FALSE; > } > > if ((! info->shared) > && bfd_get_section_by_name (abfd, ".sbss") == NULL) > { > s = bfd_make_section (abfd, ".sbss"); > if (s == NULL > || ! bfd_set_section_flags (abfd, s, SEC_RELOC | SEC_ALLOC | SEC_HAS_CONTENTS) > || ! bfd_set_section_alignment (abfd, s, 3)) > return FALSE; > } > 5306a5365 > case R_MIPS_QNX_COPY: 5412a5472 > case R_MIPS_QNX_COPY: 5732c5792,5793 < asection *s; --- > asection *s, *sreldyn = NULL; > int power_of_two; 5735a5797,5802 > /* This will make sure that the dynamic object is put into the GOT */ > if ( h->got.offset == -1 ) > { > h->got.offset = 1; > } > 5738a5806 > || (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) 5756a5825 > sreldyn = bfd_get_section_by_name (dynobj, ".rel.dyn"); 5802a5872,5904 > /* If this symbol is not defined in a regular file, then set > the symbol to the stub location. This is required to make > function pointers compare as equal between the normal > executable and the shared library. */ > if ((h->elf_link_hash_flags & ELF_LINK_HASH_DEF_REGULAR) == 0) > { > /* We need .stub section. */ > s = bfd_get_section_by_name (dynobj, > MIPS_ELF_STUB_SECTION_NAME (dynobj)); > BFD_ASSERT (s != NULL); > > h->root.u.def.section = s; > h->root.u.def.value = s->_raw_size; > > h->elf_link_hash_flags |= ELF_LINK_HASH_DEF_REGULAR; > if ( sreldyn != NULL ) { > sreldyn->_raw_size -= hmips->possibly_dynamic_relocs * sizeof (Elf32_External_Rel); > if ( sreldyn->_raw_size == sizeof(Elf32_External_Rel) ) { > sreldyn->reloc_count--; > sreldyn->_raw_size = 0; > } > } > > /* XXX Write this stub address somewhere. */ > h->plt.offset = s->_raw_size; > > /* Make room for this stub code. */ > s->_raw_size += MIPS_FUNCTION_STUB_SIZE; > > /* The last half word of the stub will be filled with the index > of this symbol in .dynsym section. */ > return TRUE; > } 5820a5923,5976 > if (info->shared) > return TRUE; > /* In this case, it is a data reference; we must therefore allocate it > in the bss/sbss, and generate a copy relocation for it. > */ > if(h->size <= elf_gp_size (dynobj)) > s = bfd_get_section_by_name(dynobj, ".sbss"); > else > s = bfd_get_section_by_name(dynobj, ".bss"); > BFD_ASSERT (s != NULL); > > /* Now we need to set up a copy relocation for this object */ > /* Come back and check flags here for QNX_COPY... */ > if (1 || (h->root.u.def.section->flags & SEC_ALLOC) != 0) > { > asection *srel; > srel = bfd_get_section_by_name(dynobj, ".rel.bss"); > BFD_ASSERT (srel != NULL); > srel->_raw_size += sizeof (Elf32_External_Rel); > h->elf_link_hash_flags |= ELF_LINK_HASH_NEEDS_COPY; > > if ( sreldyn != NULL ) { > sreldyn->_raw_size -= hmips->possibly_dynamic_relocs * sizeof (Elf32_External_Rel); > if ( sreldyn->_raw_size == sizeof(Elf32_External_Rel) ) { > sreldyn->reloc_count--; > sreldyn->_raw_size = 0; > } > } > } > > /* We need to figure out the alignment required for this symbol. I > have no idea how ELF linkers handle this. */ > power_of_two = bfd_log2 (h->size); > if (power_of_two > 3) > power_of_two = 3; > > /* Apply the required alignment. */ > s->_raw_size = BFD_ALIGN (s->_raw_size, > (bfd_size_type) (1 << power_of_two)); > if (power_of_two > bfd_get_section_alignment (dynobj, s)) > { > if (! bfd_set_section_alignment (dynobj, s, power_of_two)) > return FALSE; > } > > /* Define the symbol as being at this point in the section. */ > h->root.u.def.section = s; > h->root.u.def.value = s->_raw_size; > > /* Increment the section size to make room for the symbol. */ > s->_raw_size += h->size; > /* Work around bug in sbss handling */ > s->_cooked_size = s->_raw_size; > 6146c6302,6303 < if (mips_elf_rel_dyn_section (dynobj, FALSE)) --- > if ((mips_elf_rel_dyn_section (dynobj, FALSE)) > ||(bfd_get_section_by_name (dynobj, ".rel.bss"))) 6689c6846 < struct mips_got_info *g, *gg; --- > struct mips_got_info *g = NULL, *gg; 6691a6849,6852 > flagword flags; > > /* To see if we are linking PIC */ > flags = elf_elfheader (output_bfd)->e_flags; 6696a6858,6863 > sgot = mips_elf_got_section (dynobj, FALSE); > BFD_ASSERT (sgot != NULL); > BFD_ASSERT (elf_section_data (sgot) != NULL); > g = mips_elf_section_data (sgot)->u.got_info; > BFD_ASSERT (g != NULL); > 6710,6713d6876 < /* FIXME: Can h->dynindex be more than 64K? */ < if (h->dynindx & 0xffff0000) < return FALSE; < 6714a6878,6879 > if ((flags & EF_MIPS_PIC) || (flags & EF_MIPS_CPIC)) > { 6716a6882,6887 > > > /* FIXME: Can h->dynindex be more than 64K? */ > if (h->dynindx & 0xffff0000) > return FALSE; > 6718a6890,6904 > } > else /* Non-pic case: stub is used to jump to shared lib */ > { > bfd_size_type offset; > > if(g->global_gotsym) > offset = (h->dynindx - g->global_gotsym->dynindx + g->local_gotno) * 4; > else > offset = (h->dynindx + g->local_gotno) * 4; > bfd_put_32 (output_bfd, (STUB_LW(output_bfd) & 0xffff0000) | > (0xffff & (0x8010 + offset)), stub); > bfd_put_32 (output_bfd, STUB_QNX_JR, stub+4); > bfd_put_32 (output_bfd, STUB_QNX_NOP, stub+8); > bfd_put_32 (output_bfd, STUB_QNX_NOP, stub+12); > } 6731c6917,6924 < sym->st_value = gval; --- > if ((flags & EF_MIPS_PIC) || (flags & EF_MIPS_CPIC) || !info->shared) > { > sym->st_value = gval; > } > else > { > sym->st_value = 0; > } 6733a6927 > #if 0 6741a6936 > #endif 6911a7107,7128 > /* Finish handling the QNX_COPY relocs if there are any */ > if (h->elf_link_hash_flags & ELF_LINK_HASH_NEEDS_COPY) > { > asection *s; > Elf_Internal_Rela rel; > > /* Set up the copy reloc */ > BFD_ASSERT (h->dynindx != -1); > s = bfd_get_section_by_name (h->root.u.def.section->owner, > ".rel.bss"); > BFD_ASSERT (s != NULL); > > rel.r_offset = (h->root.u.def.value > + h->root.u.def.section->output_section->vma > + h->root.u.def.section->output_offset); > rel.r_info = ELF32_R_INFO (h->dynindx, R_MIPS_QNX_COPY); > bfd_elf32_swap_reloc_out (output_bfd, &rel, > ( s->contents > + s->reloc_count)); > ++s->reloc_count; > } > 6974a7192 > if (s == NULL) s = bfd_get_section_by_name (dynobj, ".rel.bss"); Index: libbfd.h =================================================================== RCS file: /cvs/src/src/bfd/libbfd.h,v retrieving revision 1.88 diff -r1.88 libbfd.h 874a875 > "BFD_RELOC_MIPS_QNX_COPY", Index: reloc.c =================================================================== RCS file: /cvs/src/src/bfd/reloc.c,v retrieving revision 1.86 diff -r1.86 reloc.c 2131a2132,2134 > ENUMX > BFD_RELOC_MIPS_QNX_COPY > COMMENT