- bool is_pcrel = (r_type == elfcpp::R_386_PC32
- || r_type == elfcpp::R_386_PC16
- || r_type == elfcpp::R_386_PC8);
-
- if (gsym->is_from_dynobj()
- || (parameters->output_is_shared()
- && gsym->is_preemptible()))
- {
- // (a) This symbol is defined in a dynamic object. If it is a
- // function, we make a PLT entry. Otherwise we need to
- // either generate a COPY reloc or copy this reloc.
- // (b) We are building a shared object and this symbol is
- // preemptible. If it is a function, we make a PLT entry.
- // Otherwise, we copy the reloc.
- if (gsym->type() == elfcpp::STT_FUNC)
- {
- target->make_plt_entry(symtab, layout, gsym);
-
- // If this is not a PC relative reference, then we may
- // be taking the address of the function. In that case
- // we need to set the entry in the dynamic symbol table
- // to the address of the PLT entry. We will also need to
- // create a dynamic relocation.
- if (!is_pcrel)
- {
- if (gsym->is_from_dynobj())
- gsym->set_needs_dynsym_value();
- if (parameters->output_is_position_independent())
- {
- // FIXME: If this is an 8-bit or 16-bit
- // relocation, R_386_RELATIVE won't work.
- gold_assert(r_type != elfcpp::R_386_16
- && r_type != elfcpp::R_386_8);
-
- Reloc_section* rel_dyn =
- target->rel_dyn_section(layout);
- rel_dyn->add_local(object, 0, elfcpp::R_386_RELATIVE,
- data_shndx, reloc.get_r_offset());
- }
- }
- }
- else if (parameters->output_is_shared())
- {
- // We do not make COPY relocs in shared objects.
+ // Make a PLT entry if necessary.
+ if (gsym->needs_plt_entry())
+ {
+ target->make_plt_entry(symtab, layout, gsym);
+ // Since this is not a PC-relative relocation, we may be
+ // taking the address of a function. In that case we need to
+ // set the entry in the dynamic symbol table to the address of
+ // the PLT entry.
+ if (gsym->is_from_dynobj())
+ gsym->set_needs_dynsym_value();
+ }
+ // Make a dynamic relocation if necessary.
+ if (gsym->needs_dynamic_reloc(true, false))
+ {
+ if (target->may_need_copy_reloc(gsym))
+ {
+ target->copy_reloc(&options, symtab, layout, object, data_shndx,
+ gsym, reloc);
+ }
+ else if (r_type == elfcpp::R_386_32
+ && gsym->can_use_relative_reloc(false))
+ {
+ Reloc_section* rel_dyn = target->rel_dyn_section(layout);
+ rel_dyn->add_local(object, 0, elfcpp::R_386_RELATIVE, data_shndx,
+ reloc.get_r_offset());
+ }
+ else
+ {