00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 static an_object_file_ptr p_obj_ir_list_head = NULL;
00036
00037
00038
00039
00040
00041
00042
00043 #ifdef TARG_MIPS
00044 void
00045 add_ir (an_object_file_ptr p_obj)
00046 {
00047 p_obj->next = p_obj_ir_list_head;
00048 p_obj_ir_list_head = p_obj;
00049 num_objects_linked++;
00050 num_ir++;
00051 }
00052
00053 #else
00054 #endif
00055
00056
00057
00058
00059
00060
00061
00062 #ifdef TARG_MIPS
00063 an_object_file_ptr
00064 get_next_ir (an_object_file_ptr p_obj)
00065 {
00066 if (p_obj == 0)
00067 return (p_obj_ir_list_head);
00068 else
00069 return (p_obj->next);
00070
00071 }
00072
00073 #else
00074 #endif
00075
00076
00077
00078
00079
00080
00081
00082
00083 #ifdef TARG_MIPS
00084 static void
00085 reload (an_object_file_ptr pobj, string path)
00086 {
00087 string old_name = pobj->name;
00088 unsigned old_name_index = pobj->name_ndx;
00089 int fd;
00090
00091 unread_sections (pobj);
00092 unread_obj (pobj, FALSE);
00093 BZERO (pobj, sizeof(an_object_file));
00094 pobj->other_name = old_name;
00095 pobj->other_name_ndx = old_name_index;
00096 pobj->name = path;
00097 pobj->name_ndx = string_find_offset(path);
00098
00099
00100 fd = open_file (path, TRUE, FALSE, 0);
00101 if (!use_mmap)
00102 pobj->access_method = AM_READ;
00103 pobj->ftype = read_headers (pobj, fd, FALSE);
00104 LD_ASSERT (pobj->ftype == FT_OBJ, thisfile,
00105 "incorrect file type from back end");
00106
00107 add_object (pobj);
00108 msg(ER_DEFAULT , ERN_LOAD_OBJ, num_objects_linked, pobj->name);
00109 if (bsdmap)
00110 printf("%s\n", pobj->other_name);
00111 process_object (pobj);
00112 if (optsym[OPTSYM_MDEPEND].num)
00113 update_make_depend (pobj->other_name);
00114 unread_sections (pobj);
00115 close (fd);
00116 delay_load = DL_DEFAULT;
00117 if (hides != HS_IGNORE) {
00118 hides = HS_DEFAULT;
00119 }
00120 }
00121
00122 #else
00123 #endif
00124
00125
00126
00127
00128
00129
00130 asymbol* ext = (asymbol *) pext;
00131 ext->udata.whirl_st_idx = st_idx;
00132 }
00133
00134
00135
00136
00137
00138
00139
00140
00141 ST_IDX
00142 ld_get_st_idx (void* pext)
00143 {
00144 const asymbol* ext = (asymbol *) pext;
00145
00146 return (ext->udata.whirl_st_idx);
00147 }
00148
00149
00150
00151
00152
00153
00154
00155 int
00156 ld_resolved_to_obj (void* pext, void* abfd)
00157 {
00158 const asymbol* ext = (asymbol *) pext;
00159
00160 return (ext->the_bfd == (struct _bfd *)abfd);
00161 }
00162
00163
00164
00165
00166
00167
00168
00169 #ifdef TARG_MIPS
00170 INT
00171 Count_elf_external_gots (void)
00172 {
00173 int i;
00174 int count = 0;
00175 EXTSYM *table;
00176
00177 table = ext_tbl.u.ext.buf;
00178 for (i = 0; i < ext_tbl.u.ext.num; i++) {
00179 EXTSYM *pext = table + i;
00180 int address_taken;
00181
00182
00183
00184
00185 if (pext->u0.whirl_st_idx != WHIRL_ST_IDX_UNINITIALIZED &&
00186 pext->u0.whirl_st_idx != WHIRL_ST_IDX_NOT_AVAILABLE)
00187 continue;
00188
00189
00190
00191
00192
00193 if (ld_ipa_opt[LD_IPA_SHARABLE].flag == F_CALL_SHARED) {
00194
00195
00196
00197
00198 if (!IS_UNDEF(pext->ext->st_shndx))
00199 address_taken = 0;
00200 else
00201 address_taken = pext->flags & MF_ADDRESS_TAKEN;
00202 }
00203
00204 if ( (pext->used) ||
00205 (ELF_ST_BIND(pext->ext->st_info) == STB_WEAK) ||
00206 ( IS_UNDEF(pext->ext->st_shndx) &&
00207 #ifdef _64BIT_OBJECTS
00208 (pext->ext->st_other == STO_HIDDEN) ||
00209 ( (pext->ext->st_other == STO_INTERNAL) &&
00210 (ELF_ST_TYPE(pext->ext->st_info) == STT_OBJECT)) ||
00211 #endif
00212 ((IS_DEFAULT(pext)) || address_taken))) {
00213 count++;
00214 #ifdef DEBUG
00215 printf("symbol (used = %d, address_taken = %d, is_default = %d ------- %s ------------",
00216 pext->used?1:0,
00217 address_taken?1:0,
00218 pext->ext->st_other,
00219 ext_tbl.str.buf+pext->iss);
00220 printf("has GOT entry\n");
00221 #endif
00222 }
00223 }
00224 return count;
00225 }
00226 #else
00227 #endif
00228
00229
00230