Index: bfd/elfxx-mips.c =================================================================== RCS file: /cvs/src/src/bfd/elfxx-mips.c,v retrieving revision 1.53 diff -u -p -w -r1.53 elfxx-mips.c --- bfd/elfxx-mips.c 9 May 2003 02:27:09 -0000 1.53 +++ bfd/elfxx-mips.c 21 May 2003 21:50:33 -0000 @@ -163,8 +163,7 @@ struct mips_elf_hash_sort_data long min_got_dynindx; /* The greatest dynamic symbol table index corresponding to a symbol with a GOT entry that is not referenced (e.g., a dynamic symbol - with dynamic relocations pointing to it from non-primary - GOTs). */ + with dynamic relocations pointing to it from non-primary GOTs). */ long max_unref_got_dynindx; /* The greatest dynamic symbol table index not corresponding to a symbol without a GOT entry. */ @@ -246,8 +245,7 @@ struct mips_elf_link_hash_table struct extsym_info { - bfd *abfd; - struct bfd_link_info *info; + bfd *abfd; struct bfd_link_info *info; struct ecoff_debug_info *debug; const struct ecoff_debug_swap *swap; bfd_boolean failed; @@ -8380,17 +8378,6 @@ _bfd_mips_elf_final_link (abfd, info) scRData, scSData, scSBss, scBss }; - /* If all the things we linked together were PIC, but we're - producing an executable (rather than a shared object), then the - resulting file is CPIC (i.e., it calls PIC code.) */ - if (!info->shared - && !info->relocateable - && elf_elfheader (abfd)->e_flags & EF_MIPS_PIC) - { - elf_elfheader (abfd)->e_flags &= ~EF_MIPS_PIC; - elf_elfheader (abfd)->e_flags |= EF_MIPS_CPIC; - } - /* We'd carefully arranged the dynamic symbol indices, and then the generic size_dynamic_sections renumbered them out from under us. Rather than trying somehow to prevent the renumbering, just do @@ -9250,25 +9237,22 @@ _bfd_mips_elf_merge_private_bfd_data (ib ok = TRUE; - if ((new_flags & EF_MIPS_PIC) != (old_flags & EF_MIPS_PIC)) + if (((new_flags & (EF_MIPS_PIC | EF_MIPS_CPIC)) != 0) + != ((old_flags & (EF_MIPS_PIC | EF_MIPS_CPIC)) != 0)) { - new_flags &= ~EF_MIPS_PIC; - old_flags &= ~EF_MIPS_PIC; (*_bfd_error_handler) - (_("%s: linking PIC files with non-PIC files"), + (_("%s: warning: linking PIC files with non-PIC files"), bfd_archive_filename (ibfd)); - ok = FALSE; + ok = TRUE; } - if ((new_flags & EF_MIPS_CPIC) != (old_flags & EF_MIPS_CPIC)) - { - new_flags &= ~EF_MIPS_CPIC; - old_flags &= ~EF_MIPS_CPIC; - (*_bfd_error_handler) - (_("%s: linking abicalls files with non-abicalls files"), - bfd_archive_filename (ibfd)); - ok = FALSE; - } + if (new_flags & (EF_MIPS_PIC | EF_MIPS_CPIC)) + elf_elfheader (obfd)->e_flags |= EF_MIPS_CPIC; + if (! (new_flags & EF_MIPS_PIC)) + elf_elfheader (obfd)->e_flags &= ~EF_MIPS_PIC; + + new_flags &= ~ (EF_MIPS_PIC | EF_MIPS_CPIC); + old_flags &= ~ (EF_MIPS_PIC | EF_MIPS_CPIC); /* Compare the ISAs. */ if (mips_32bit_flags_p (old_flags) != mips_32bit_flags_p (new_flags)) Index: gas/config/tc-mips.c =================================================================== RCS file: /cvs/src/src/gas/config/tc-mips.c,v retrieving revision 1.207 diff -u -p -w -r1.207 tc-mips.c --- gas/config/tc-mips.c 7 May 2003 05:10:45 -0000 1.207 +++ gas/config/tc-mips.c 21 May 2003 21:50:36 -0000 @@ -131,6 +131,9 @@ enum mips_abi_level /* MIPS ABI we are using for this output file. */ static enum mips_abi_level mips_abi = NO_ABI; +/* Whether or not we have code that can call pic code. */ +int mips_abicalls = FALSE; + /* This is the set of options which may be modified by the .set pseudo-op. We use a struct so that .set push and .set pop are more reliable. */ @@ -11038,6 +11041,7 @@ md_parse_option (c, arg) return 0; } mips_pic = SVR4_PIC; + mips_abicalls = TRUE; if (g_switch_seen && g_switch_value != 0) { as_bad (_("-G may not be used with SVR4 PIC code")); @@ -11053,6 +11057,7 @@ md_parse_option (c, arg) return 0; } mips_pic = NO_PIC; + mips_abicalls = FALSE; break; /* The -xgot option tells the assembler to use 32 offsets when @@ -12430,7 +12435,10 @@ s_option (x) if (i == 0) mips_pic = NO_PIC; else if (i == 2) + { mips_pic = SVR4_PIC; + mips_abicalls = TRUE; + } else as_bad (_(".option pic%d not supported"), i); @@ -12654,6 +12662,7 @@ s_abicalls (ignore) int ignore ATTRIBUTE_UNUSED; { mips_pic = SVR4_PIC; + mips_abicalls = TRUE; if (USE_GLOBAL_POINTER_OPT) { if (g_switch_seen && g_switch_value != 0) @@ -14440,7 +14449,12 @@ mips_elf_final_processing () if (mips_any_noreorder) elf_elfheader (stdoutput)->e_flags |= EF_MIPS_NOREORDER; if (mips_pic != NO_PIC) + { elf_elfheader (stdoutput)->e_flags |= EF_MIPS_PIC; + elf_elfheader (stdoutput)->e_flags |= EF_MIPS_CPIC; + } + if (mips_abicalls) + elf_elfheader (stdoutput)->e_flags |= EF_MIPS_CPIC; /* Set MIPS ELF flags for ASEs. */ if (file_ase_mips16)