| File: | src/gnu/usr.bin/binutils-2.17/obj/ld/eelf_i386.c |
| Warning: | line 187, column 3 Value stored to 'dot' is never read |
Press '?' to see keyboard shortcuts
Keyboard shortcuts:
| 1 | /* This file is is generated by a shell script. DO NOT EDIT! */ |
| 2 | |
| 3 | /* 32 bit ELF emulation code for elf_i386 |
| 4 | Copyright 1991, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, |
| 5 | 2002, 2003, 2004, 2005, 2006 Free Software Foundation, Inc. |
| 6 | Written by Steve Chamberlain <sac@cygnus.com> |
| 7 | ELF support by Ian Lance Taylor <ian@cygnus.com> |
| 8 | |
| 9 | This file is part of GLD, the Gnu Linker. |
| 10 | |
| 11 | This program is free software; you can redistribute it and/or modify |
| 12 | it under the terms of the GNU General Public License as published by |
| 13 | the Free Software Foundation; either version 2 of the License, or |
| 14 | (at your option) any later version. |
| 15 | |
| 16 | This program is distributed in the hope that it will be useful, |
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | GNU General Public License for more details. |
| 20 | |
| 21 | You should have received a copy of the GNU General Public License |
| 22 | along with this program; if not, write to the Free Software |
| 23 | Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */ |
| 24 | |
| 25 | #define TARGET_IS_elf_i386 |
| 26 | |
| 27 | #include "config.h" |
| 28 | #include "bfd.h" |
| 29 | #include "sysdep.h" |
| 30 | #include "libiberty.h" |
| 31 | #include "safe-ctype.h" |
| 32 | #include "getopt.h" |
| 33 | |
| 34 | #include "bfdlink.h" |
| 35 | |
| 36 | #include "ld.h" |
| 37 | #include "ldmain.h" |
| 38 | #include "ldmisc.h" |
| 39 | #include "ldexp.h" |
| 40 | #include "ldlang.h" |
| 41 | #include "ldfile.h" |
| 42 | #include "ldemul.h" |
| 43 | #include <ldgram.h> |
| 44 | #include "elf/common.h" |
| 45 | #include "elf-bfd.h" |
| 46 | |
| 47 | /* Declare functions used by various EXTRA_EM_FILEs. */ |
| 48 | static void gldelf_i386_before_parse (void); |
| 49 | static void gldelf_i386_after_open (void); |
| 50 | static void gldelf_i386_before_allocation (void); |
| 51 | static bfd_boolean gldelf_i386_place_orphan (asection *s); |
| 52 | static void gldelf_i386_layout_sections_again (void); |
| 53 | static void gldelf_i386_finish (void) ATTRIBUTE_UNUSED__attribute__ ((__unused__)); |
| 54 | |
| 55 | #include <sys/types.h> |
| 56 | #include <dirent.h> |
| 57 | |
| 58 | /* Search a directory for a .so file. */ |
| 59 | |
| 60 | static char * gldelf_i386_search_dir_needed (const char *dirlist, const char *filename); |
| 61 | |
| 62 | static char * gldelf_i386_search_dir (const char *dirname, |
| 63 | const char *filename, int req_maj, int req_min); |
| 64 | |
| 65 | static char * gldelf_i386_split_lib_name (char *name, int *pmaj, |
| 66 | int *pmin); |
| 67 | |
| 68 | /* THIS FUNCTION MODIFIES THE name ARGUMENT string */ |
| 69 | static char * |
| 70 | gldelf_i386_split_lib_name (name, pmaj, pmin) |
| 71 | char *name; |
| 72 | int *pmaj, *pmin; |
| 73 | { |
| 74 | char*eptr, *lib = name; |
| 75 | char *s; |
| 76 | int found_so = 0; |
| 77 | |
| 78 | *pmaj = -1; |
| 79 | *pmin = -1; |
| 80 | |
| 81 | if (strncmp(lib, "lib", 3) == 0) |
| 82 | lib += 3; |
| 83 | |
| 84 | s = lib; |
| 85 | while (found_so == 0) |
| 86 | { |
| 87 | s = strstr(s, ".so"); |
| 88 | |
| 89 | /* if .so not found, return not found, invalid lib name */ |
| 90 | if (s == NULL((void*)0)) |
| 91 | { |
| 92 | return NULL((void*)0); |
| 93 | } |
| 94 | |
| 95 | /* if .so is at end of string, fine return with pmaj/pmin -1 */ |
| 96 | if (s[3] == '\0') |
| 97 | { |
| 98 | *s = '\0'; |
| 99 | return lib; |
| 100 | } |
| 101 | |
| 102 | if (s[3] == '.') |
| 103 | { |
| 104 | *s = '\0'; |
| 105 | found_so = 1; |
| 106 | } |
| 107 | /* skip over the ".so" */ |
| 108 | s += 3; |
| 109 | } |
| 110 | |
| 111 | |
| 112 | /* lib[name].so.[M].[N] */ |
| 113 | /* s ^ */ |
| 114 | s += 1; |
| 115 | |
| 116 | /* lib[name].so.[M].[N] */ |
| 117 | /* s ^ */ |
| 118 | *pmaj = strtoul (s, &eptr, 10); |
| 119 | |
| 120 | /* lib[name].so.[M]X... */ |
| 121 | /* eptr ^ */ |
| 122 | if (*eptr != '.' || s == eptr) |
| 123 | return NULL((void*)0); /* invalid, must have minor */ |
| 124 | |
| 125 | s = eptr+1; |
| 126 | |
| 127 | /* lib[name].so.[M].[N] */ |
| 128 | /* s ^ */ |
| 129 | *pmin = strtoul (s, &eptr, 10); |
| 130 | |
| 131 | /* lib[name].so.[M].[N] */ |
| 132 | /* eptr ^ */ |
| 133 | if (*eptr != '\0' || s == eptr) |
| 134 | return NULL((void*)0); /* minor must be last field of library */ |
| 135 | |
| 136 | return lib; |
| 137 | } |
| 138 | |
| 139 | static char * |
| 140 | gldelf_i386_search_dir_needed (dirlist, filename) |
| 141 | const char *dirlist; |
| 142 | const char *filename; |
| 143 | { |
| 144 | char *dlist, *dlist_alloc, *dir; |
| 145 | char *fnam, *fnam_alloc, *lib; |
| 146 | char *found = NULL((void*)0); |
| 147 | int maj = -1, min = -1; |
| 148 | |
| 149 | dlist_alloc = dlist = xstrdup(dirlist); |
| 150 | fnam_alloc = fnam = xstrdup(filename); |
| 151 | |
| 152 | lib = gldelf_i386_split_lib_name(fnam, &maj, &min); |
| 153 | |
| 154 | while (lib != NULL((void*)0) && found == NULL((void*)0)) |
| 155 | { |
| 156 | dir = strsep(&dlist, ":"); |
| 157 | if (dir == NULL((void*)0)) |
| 158 | break; |
| 159 | if (*dir == '\0') |
| 160 | continue; /* skip dirlist of ...::... */ |
| 161 | found = gldelf_i386_search_dir(dir, lib, maj, min); |
| 162 | } |
| 163 | |
| 164 | free(dlist_alloc); |
| 165 | free(fnam_alloc); |
| 166 | return found; |
| 167 | } |
| 168 | |
| 169 | |
| 170 | static char * |
| 171 | gldelf_i386_search_dir (dirname, filename, req_maj, req_min) |
| 172 | const char *dirname; |
| 173 | const char *filename; |
| 174 | int req_maj, req_min; |
| 175 | { |
| 176 | const char *dot; |
| 177 | unsigned int len; |
| 178 | char *found; |
| 179 | int max_maj, max_min; |
| 180 | DIR *dir; |
| 181 | struct dirent *entry; |
| 182 | unsigned int dirnamelen; |
| 183 | char *full_path; |
| 184 | int statval; |
| 185 | struct stat st; |
| 186 | |
| 187 | dot = strchr (filename, '.'); |
Value stored to 'dot' is never read | |
| 188 | len = strlen (filename); |
| 189 | found = NULL((void*)0); |
| 190 | max_maj = max_min = 0; |
| 191 | |
| 192 | dir = opendir (dirname); |
| 193 | if (dir == NULL((void*)0)) |
| 194 | return NULL((void*)0); |
| 195 | dirnamelen = strlen (dirname); |
| 196 | |
| 197 | while ((entry = readdir (dir)) != NULL((void*)0)) |
| 198 | { |
| 199 | const char *s; |
| 200 | char *eptr, *eptr1; |
| 201 | int found_maj, found_min; |
| 202 | |
| 203 | if (strncmp (entry->d_name, "lib", 3) != 0 |
| 204 | || strncmp (entry->d_name + 3, filename, len) != 0) |
| 205 | continue; |
| 206 | |
| 207 | /* We accept libfoo.so without a version number, even though the |
| 208 | native linker does not. This is more convenient for packages |
| 209 | which just generate .so files for shared libraries, as on ELF |
| 210 | systems. */ |
| 211 | if (strncmp (entry->d_name + 3 + len, ".so", 3) != 0) |
| 212 | continue; |
| 213 | |
| 214 | if (entry->d_name[6 + len] == '\0') |
| 215 | ; |
| 216 | else if (entry->d_name[6 + len] == '.' |
| 217 | && ISDIGIT ((unsigned char) entry->d_name[7 + len])(_sch_istable[((unsigned char) entry->d_name[7 + len]) & 0xff] & (unsigned short)(_sch_isdigit))) |
| 218 | ; |
| 219 | else |
| 220 | continue; |
| 221 | |
| 222 | for (s = entry->d_name + 6 + len; *s != '\0'; s++) |
| 223 | if (*s != '.' && ! ISDIGIT ((unsigned char) *s)(_sch_istable[((unsigned char) *s) & 0xff] & (unsigned short)(_sch_isdigit))) |
| 224 | break; |
| 225 | if (*s != '\0') |
| 226 | continue; |
| 227 | |
| 228 | /* We've found a .so file. Work out the major and minor |
| 229 | version numbers. */ |
| 230 | found_maj = -1; |
| 231 | found_min = -1; |
| 232 | |
| 233 | /* do allow libN.so */ |
| 234 | if (entry->d_name[6 + len] == '.') { |
| 235 | found_maj = strtoul (entry->d_name + 7 + len, &eptr, 10); |
| 236 | |
| 237 | /* do not support libN.so. or libN.so.X */ |
| 238 | if (*eptr != '.' || ((entry->d_name + 3 + len) == eptr)) |
| 239 | continue; |
| 240 | |
| 241 | found_min = strtoul (eptr+1, &eptr1, 10); |
| 242 | |
| 243 | /* do not support libN.so.X. or libN.so.X.Y.[anything] */ |
| 244 | if (*eptr1 != '\0' || (eptr+1 == eptr1)) |
| 245 | continue; |
| 246 | } |
| 247 | |
| 248 | /* Make sure the file really exists (ignore broken symlinks). */ |
| 249 | full_path = xmalloc (dirnamelen + 1 + strlen (entry->d_name) + 1); |
| 250 | sprintf (full_path, "%s/%s", dirname, entry->d_name); |
| 251 | statval = stat (full_path, &st); |
| 252 | free (full_path); |
| 253 | if (statval != 0) |
| 254 | continue; |
| 255 | |
| 256 | /* We've found a match for the name we are searching for. See |
| 257 | if this is the version we should use. */ |
| 258 | if (((req_maj == -1) && (found == NULL((void*)0) |
| 259 | || (found_maj > max_maj) |
| 260 | || (found_maj == max_maj && (found_min > max_min)))) |
| 261 | || ((found_maj == req_maj) && (found_min >= req_min) |
| 262 | && (found_min > max_min))) |
| 263 | { |
| 264 | if (found != NULL((void*)0)) |
| 265 | free (found); |
| 266 | found = (char *) xmalloc (dirnamelen + strlen (entry->d_name) + 2); |
| 267 | sprintf (found, "%s/%s", dirname, entry->d_name); |
| 268 | max_maj = found_maj; |
| 269 | max_min = found_min; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | closedir (dir); |
| 274 | |
| 275 | return found; |
| 276 | } |
| 277 | |
| 278 | |
| 279 | static void |
| 280 | gldelf_i386_before_parse (void) |
| 281 | { |
| 282 | ldfile_set_output_arch ("i386", bfd_arch_i386); |
| 283 | config.dynamic_link = TRUE1; |
| 284 | config.has_shared = TRUE1; |
| 285 | } |
| 286 | |
| 287 | /* Handle as_needed DT_NEEDED. */ |
| 288 | |
| 289 | static bfd_boolean |
| 290 | gldelf_i386_load_symbols (lang_input_statement_type *entry) |
| 291 | { |
| 292 | int class = 0; |
| 293 | |
| 294 | /* Tell the ELF linker that we don't want the output file to have a |
| 295 | DT_NEEDED entry for this file, unless it is used to resolve |
| 296 | references in a regular object. */ |
| 297 | if (entry->as_needed) |
| 298 | class = DYN_AS_NEEDED; |
| 299 | |
| 300 | /* Tell the ELF linker that we don't want the output file to have a |
| 301 | DT_NEEDED entry for any dynamic library in DT_NEEDED tags from |
| 302 | this file at all. */ |
| 303 | if (!entry->add_needed) |
| 304 | class |= DYN_NO_ADD_NEEDED; |
| 305 | |
| 306 | if (entry->just_syms_flag |
| 307 | && (bfd_get_file_flags (entry->the_bfd)((entry->the_bfd)->flags) & DYNAMIC0x40) != 0) |
| 308 | einfo (_("%P%F: --just-symbols may not be used on DSO: %B\n")("%P%F: --just-symbols may not be used on DSO: %B\n"), |
| 309 | entry->the_bfd); |
| 310 | |
| 311 | if (!class |
| 312 | || (bfd_get_file_flags (entry->the_bfd)((entry->the_bfd)->flags) & DYNAMIC0x40) == 0) |
| 313 | return FALSE0; |
| 314 | |
| 315 | bfd_elf_set_dyn_lib_class (entry->the_bfd, class); |
| 316 | |
| 317 | /* Continue on with normal load_symbols processing. */ |
| 318 | return FALSE0; |
| 319 | } |
| 320 | |
| 321 | /* These variables are required to pass information back and forth |
| 322 | between after_open and check_needed and stat_needed and vercheck. */ |
| 323 | |
| 324 | static struct bfd_link_needed_list *global_needed; |
| 325 | static struct stat global_stat; |
| 326 | static lang_input_statement_type *global_found; |
| 327 | static struct bfd_link_needed_list *global_vercheck_needed; |
| 328 | static bfd_boolean global_vercheck_failed; |
| 329 | |
| 330 | |
| 331 | /* On Linux, it's possible to have different versions of the same |
| 332 | shared library linked against different versions of libc. The |
| 333 | dynamic linker somehow tags which libc version to use in |
| 334 | /etc/ld.so.cache, and, based on the libc that it sees in the |
| 335 | executable, chooses which version of the shared library to use. |
| 336 | |
| 337 | We try to do a similar check here by checking whether this shared |
| 338 | library needs any other shared libraries which may conflict with |
| 339 | libraries we have already included in the link. If it does, we |
| 340 | skip it, and try to find another shared library farther on down the |
| 341 | link path. |
| 342 | |
| 343 | This is called via lang_for_each_input_file. |
| 344 | GLOBAL_VERCHECK_NEEDED is the list of objects needed by the object |
| 345 | which we are checking. This sets GLOBAL_VERCHECK_FAILED if we find |
| 346 | a conflicting version. */ |
| 347 | |
| 348 | static void |
| 349 | gldelf_i386_vercheck (lang_input_statement_type *s) |
| 350 | { |
| 351 | const char *soname; |
| 352 | struct bfd_link_needed_list *l; |
| 353 | |
| 354 | if (global_vercheck_failed) |
| 355 | return; |
| 356 | if (s->the_bfd == NULL((void*)0) |
| 357 | || (bfd_get_file_flags (s->the_bfd)((s->the_bfd)->flags) & DYNAMIC0x40) == 0) |
| 358 | return; |
| 359 | |
| 360 | soname = bfd_elf_get_dt_soname (s->the_bfd); |
| 361 | if (soname == NULL((void*)0)) |
| 362 | soname = lbasename (bfd_get_filename (s->the_bfd)((char *) (s->the_bfd)->filename)); |
| 363 | |
| 364 | for (l = global_vercheck_needed; l != NULL((void*)0); l = l->next) |
| 365 | { |
| 366 | const char *suffix; |
| 367 | |
| 368 | if (strcmp (soname, l->name) == 0) |
| 369 | { |
| 370 | /* Probably can't happen, but it's an easy check. */ |
| 371 | continue; |
| 372 | } |
| 373 | |
| 374 | if (strchr (l->name, '/') != NULL((void*)0)) |
| 375 | continue; |
| 376 | |
| 377 | suffix = strstr (l->name, ".so."); |
| 378 | if (suffix == NULL((void*)0)) |
| 379 | continue; |
| 380 | |
| 381 | suffix += sizeof ".so." - 1; |
| 382 | |
| 383 | if (strncmp (soname, l->name, suffix - l->name) == 0) |
| 384 | { |
| 385 | /* Here we know that S is a dynamic object FOO.SO.VER1, and |
| 386 | the object we are considering needs a dynamic object |
| 387 | FOO.SO.VER2, and VER1 and VER2 are different. This |
| 388 | appears to be a version mismatch, so we tell the caller |
| 389 | to try a different version of this library. */ |
| 390 | global_vercheck_failed = TRUE1; |
| 391 | return; |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | |
| 396 | |
| 397 | /* See if an input file matches a DT_NEEDED entry by running stat on |
| 398 | the file. */ |
| 399 | |
| 400 | static void |
| 401 | gldelf_i386_stat_needed (lang_input_statement_type *s) |
| 402 | { |
| 403 | struct stat st; |
| 404 | const char *suffix; |
| 405 | const char *soname; |
| 406 | |
| 407 | if (global_found != NULL((void*)0)) |
| 408 | return; |
| 409 | if (s->the_bfd == NULL((void*)0)) |
| 410 | return; |
| 411 | |
| 412 | /* If this input file was an as-needed entry, and wasn't found to be |
| 413 | needed at the stage it was linked, then don't say we have loaded it. */ |
| 414 | if ((bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0) |
| 415 | return; |
| 416 | |
| 417 | if (bfd_stat (s->the_bfd, &st) != 0) |
| 418 | { |
| 419 | einfo ("%P:%B: bfd_stat failed: %E\n", s->the_bfd); |
| 420 | return; |
| 421 | } |
| 422 | |
| 423 | /* Some operating systems, e.g. Windows, do not provide a meaningful |
| 424 | st_ino; they always set it to zero. (Windows does provide a |
| 425 | meaningful st_dev.) Do not indicate a duplicate library in that |
| 426 | case. While there is no guarantee that a system that provides |
| 427 | meaningful inode numbers will never set st_ino to zero, this is |
| 428 | merely an optimization, so we do not need to worry about false |
| 429 | negatives. */ |
| 430 | if (st.st_dev == global_stat.st_dev |
| 431 | && st.st_ino == global_stat.st_ino |
| 432 | && st.st_ino != 0) |
| 433 | { |
| 434 | global_found = s; |
| 435 | return; |
| 436 | } |
| 437 | |
| 438 | /* We issue a warning if it looks like we are including two |
| 439 | different versions of the same shared library. For example, |
| 440 | there may be a problem if -lc picks up libc.so.6 but some other |
| 441 | shared library has a DT_NEEDED entry of libc.so.5. This is a |
| 442 | heuristic test, and it will only work if the name looks like |
| 443 | NAME.so.VERSION. FIXME: Depending on file names is error-prone. |
| 444 | If we really want to issue warnings about mixing version numbers |
| 445 | of shared libraries, we need to find a better way. */ |
| 446 | |
| 447 | if (strchr (global_needed->name, '/') != NULL((void*)0)) |
| 448 | return; |
| 449 | suffix = strstr (global_needed->name, ".so."); |
| 450 | if (suffix == NULL((void*)0)) |
| 451 | return; |
| 452 | suffix += sizeof ".so." - 1; |
| 453 | |
| 454 | soname = bfd_elf_get_dt_soname (s->the_bfd); |
| 455 | if (soname == NULL((void*)0)) |
| 456 | soname = lbasename (s->filename); |
| 457 | |
| 458 | if (strncmp (soname, global_needed->name, suffix - global_needed->name) == 0) |
| 459 | einfo ("%P: warning: %s, needed by %B, may conflict with %s\n", |
| 460 | global_needed->name, global_needed->by, soname); |
| 461 | } |
| 462 | |
| 463 | struct dt_needed |
| 464 | { |
| 465 | bfd *by; |
| 466 | const char *name; |
| 467 | }; |
| 468 | |
| 469 | /* This function is called for each possible name for a dynamic object |
| 470 | named by a DT_NEEDED entry. The FORCE parameter indicates whether |
| 471 | to skip the check for a conflicting version. */ |
| 472 | |
| 473 | static bfd_boolean |
| 474 | gldelf_i386_try_needed (struct dt_needed *needed, |
| 475 | int force) |
| 476 | { |
| 477 | bfd *abfd; |
| 478 | const char *name = needed->name; |
| 479 | char *soname; |
| 480 | int class; |
| 481 | |
| 482 | abfd = bfd_openr (name, bfd_get_target (output_bfd)((output_bfd)->xvec->name)); |
| 483 | if (abfd == NULL((void*)0)) |
| 484 | return FALSE0; |
| 485 | if (! bfd_check_format (abfd, bfd_object)) |
| 486 | { |
| 487 | bfd_close (abfd); |
| 488 | return FALSE0; |
| 489 | } |
| 490 | if ((bfd_get_file_flags (abfd)((abfd)->flags) & DYNAMIC0x40) == 0) |
| 491 | { |
| 492 | bfd_close (abfd); |
| 493 | return FALSE0; |
| 494 | } |
| 495 | |
| 496 | /* For DT_NEEDED, they have to match. */ |
| 497 | if (abfd->xvec != output_bfd->xvec) |
| 498 | { |
| 499 | bfd_close (abfd); |
| 500 | return FALSE0; |
| 501 | } |
| 502 | |
| 503 | /* Check whether this object would include any conflicting library |
| 504 | versions. If FORCE is set, then we skip this check; we use this |
| 505 | the second time around, if we couldn't find any compatible |
| 506 | instance of the shared library. */ |
| 507 | |
| 508 | if (! force) |
| 509 | { |
| 510 | struct bfd_link_needed_list *needed; |
| 511 | |
| 512 | if (! bfd_elf_get_bfd_needed_list (abfd, &needed)) |
| 513 | einfo ("%F%P:%B: bfd_elf_get_bfd_needed_list failed: %E\n", abfd); |
| 514 | |
| 515 | if (needed != NULL((void*)0)) |
| 516 | { |
| 517 | global_vercheck_needed = needed; |
| 518 | global_vercheck_failed = FALSE0; |
| 519 | lang_for_each_input_file (gldelf_i386_vercheck); |
| 520 | if (global_vercheck_failed) |
| 521 | { |
| 522 | bfd_close (abfd); |
| 523 | /* Return FALSE to force the caller to move on to try |
| 524 | another file on the search path. */ |
| 525 | return FALSE0; |
| 526 | } |
| 527 | |
| 528 | /* But wait! It gets much worse. On Linux, if a shared |
| 529 | library does not use libc at all, we are supposed to skip |
| 530 | it the first time around in case we encounter a shared |
| 531 | library later on with the same name which does use the |
| 532 | version of libc that we want. This is much too horrible |
| 533 | to use on any system other than Linux. */ |
| 534 | |
| 535 | } |
| 536 | } |
| 537 | |
| 538 | /* We've found a dynamic object matching the DT_NEEDED entry. */ |
| 539 | |
| 540 | /* We have already checked that there is no other input file of the |
| 541 | same name. We must now check again that we are not including the |
| 542 | same file twice. We need to do this because on many systems |
| 543 | libc.so is a symlink to, e.g., libc.so.1. The SONAME entry will |
| 544 | reference libc.so.1. If we have already included libc.so, we |
| 545 | don't want to include libc.so.1 if they are the same file, and we |
| 546 | can only check that using stat. */ |
| 547 | |
| 548 | if (bfd_stat (abfd, &global_stat) != 0) |
| 549 | einfo ("%F%P:%B: bfd_stat failed: %E\n", abfd); |
| 550 | |
| 551 | /* First strip off everything before the last '/'. */ |
| 552 | soname = xstrdup (lbasename (abfd->filename)); |
| 553 | |
| 554 | if (trace_file_tries) |
| 555 | info_msg (_("found %s at %s\n")("found %s at %s\n"), soname, name); |
| 556 | |
| 557 | global_found = NULL((void*)0); |
| 558 | lang_for_each_input_file (gldelf_i386_stat_needed); |
| 559 | if (global_found != NULL((void*)0)) |
| 560 | { |
| 561 | /* Return TRUE to indicate that we found the file, even though |
| 562 | we aren't going to do anything with it. */ |
| 563 | free (soname); |
| 564 | return TRUE1; |
| 565 | } |
| 566 | |
| 567 | /* Specify the soname to use. */ |
| 568 | bfd_elf_set_dt_needed_name (abfd, soname); |
| 569 | |
| 570 | /* Tell the ELF linker that we don't want the output file to have a |
| 571 | DT_NEEDED entry for this file, unless it is used to resolve |
| 572 | references in a regular object. */ |
| 573 | class = DYN_DT_NEEDED; |
| 574 | |
| 575 | /* Tell the ELF linker that we don't want the output file to have a |
| 576 | DT_NEEDED entry for this file at all if the entry is from a file |
| 577 | with DYN_NO_ADD_NEEDED. */ |
| 578 | if (needed->by != NULL((void*)0) |
| 579 | && (bfd_elf_get_dyn_lib_class (needed->by) & DYN_NO_ADD_NEEDED) != 0) |
| 580 | class |= DYN_NO_NEEDED | DYN_NO_ADD_NEEDED; |
| 581 | |
| 582 | bfd_elf_set_dyn_lib_class (abfd, class); |
| 583 | |
| 584 | /* Add this file into the symbol table. */ |
| 585 | if (! bfd_link_add_symbols (abfd, &link_info)((*((abfd)->xvec->_bfd_link_add_symbols)) (abfd, &link_info ))) |
| 586 | einfo ("%F%B: could not read symbols: %E\n", abfd); |
| 587 | |
| 588 | return TRUE1; |
| 589 | } |
| 590 | |
| 591 | |
| 592 | /* Search for a needed file in a path. */ |
| 593 | |
| 594 | static bfd_boolean |
| 595 | gldelf_i386_search_needed (const char *path, |
| 596 | struct dt_needed *n, int force) |
| 597 | { |
| 598 | const char *s; |
| 599 | const char *name = n->name; |
| 600 | size_t len; |
| 601 | struct dt_needed needed; |
| 602 | |
| 603 | if (name[0] == '/') |
| 604 | return gldelf_i386_try_needed (n, force); |
| 605 | |
| 606 | if (path == NULL((void*)0) || *path == '\0') |
| 607 | return FALSE0; |
| 608 | |
| 609 | needed.by = n->by; |
| 610 | |
| 611 | { |
| 612 | char *found; |
| 613 | if ((found = gldelf_i386_search_dir_needed(path, name)) != NULL((void*)0)) { |
| 614 | needed.name = found; |
| 615 | if (gldelf_i386_try_needed (&needed, force)) { |
| 616 | return TRUE1; |
| 617 | } |
| 618 | free(found); |
| 619 | } |
| 620 | } |
| 621 | |
| 622 | needed.name = n->name; |
| 623 | |
| 624 | len = strlen (name); |
| 625 | while (1) |
| 626 | { |
| 627 | char *filename, *sset; |
| 628 | |
| 629 | s = strchr (path, ':'); |
| 630 | if (s == NULL((void*)0)) |
| 631 | s = path + strlen (path); |
| 632 | |
| 633 | filename = (char *) xmalloc (s - path + len + 2); |
| 634 | if (s == path) |
| 635 | sset = filename; |
| 636 | else |
| 637 | { |
| 638 | memcpy (filename, path, s - path); |
| 639 | filename[s - path] = '/'; |
| 640 | sset = filename + (s - path) + 1; |
| 641 | } |
| 642 | strcpy (sset, name); |
| 643 | |
| 644 | needed.name = filename; |
| 645 | if (gldelf_i386_try_needed (&needed, force)) |
| 646 | return TRUE1; |
| 647 | |
| 648 | free (filename); |
| 649 | |
| 650 | if (*s == '\0') |
| 651 | break; |
| 652 | path = s + 1; |
| 653 | } |
| 654 | |
| 655 | return FALSE0; |
| 656 | } |
| 657 | |
| 658 | |
| 659 | /* See if an input file matches a DT_NEEDED entry by name. */ |
| 660 | |
| 661 | static void |
| 662 | gldelf_i386_check_needed (lang_input_statement_type *s) |
| 663 | { |
| 664 | const char *soname; |
| 665 | |
| 666 | /* Stop looking if we've found a loaded lib. */ |
| 667 | if (global_found != NULL((void*)0) |
| 668 | && (bfd_elf_get_dyn_lib_class (global_found->the_bfd) |
| 669 | & DYN_AS_NEEDED) == 0) |
| 670 | return; |
| 671 | |
| 672 | if (s->filename == NULL((void*)0) || s->the_bfd == NULL((void*)0)) |
| 673 | return; |
| 674 | |
| 675 | /* Don't look for a second non-loaded as-needed lib. */ |
| 676 | if (global_found != NULL((void*)0) |
| 677 | && (bfd_elf_get_dyn_lib_class (s->the_bfd) & DYN_AS_NEEDED) != 0) |
| 678 | return; |
| 679 | |
| 680 | if (strcmp (s->filename, global_needed->name) == 0) |
| 681 | { |
| 682 | global_found = s; |
| 683 | return; |
| 684 | } |
| 685 | |
| 686 | if (s->search_dirs_flag) |
| 687 | { |
| 688 | const char *f = strrchr (s->filename, '/'); |
| 689 | if (f != NULL((void*)0) |
| 690 | && strcmp (f + 1, global_needed->name) == 0) |
| 691 | { |
| 692 | global_found = s; |
| 693 | return; |
| 694 | } |
| 695 | } |
| 696 | |
| 697 | soname = bfd_elf_get_dt_soname (s->the_bfd); |
| 698 | if (soname != NULL((void*)0) |
| 699 | && strcmp (soname, global_needed->name) == 0) |
| 700 | { |
| 701 | global_found = s; |
| 702 | return; |
| 703 | } |
| 704 | } |
| 705 | |
| 706 | |
| 707 | static void |
| 708 | gldelf_i386_force_readonly(lang_input_statement_type *s) |
| 709 | { |
| 710 | asection *sec; |
| 711 | |
| 712 | if (s->the_bfd == NULL((void*)0)) |
| 713 | return; |
| 714 | |
| 715 | sec = bfd_get_section_by_name (s->the_bfd, ".ctors"); |
| 716 | if (sec) |
| 717 | sec->flags |= SEC_READONLY0x008; |
| 718 | sec = bfd_get_section_by_name (s->the_bfd, ".dtors"); |
| 719 | if (sec) |
| 720 | sec->flags |= SEC_READONLY0x008; |
| 721 | } |
| 722 | |
| 723 | /* This is called after all the input files have been opened. */ |
| 724 | |
| 725 | static void |
| 726 | gldelf_i386_after_open (void) |
| 727 | { |
| 728 | struct bfd_link_needed_list *needed, *l; |
| 729 | |
| 730 | /* We only need to worry about this when doing a final link. */ |
| 731 | if (link_info.relocatable || !link_info.executable) |
| 732 | return; |
| 733 | |
| 734 | /* If we don't have a .dynamic section, we have no relocations, and |
| 735 | we can make .got, .ctors and .dtors read-only. This will make |
| 736 | the segment containing those sections to be read-only in static |
| 737 | executables. */ |
| 738 | if (link_info.hash->type == bfd_link_elf_hash_table |
| 739 | && !elf_hash_table (&link_info)((struct elf_link_hash_table *) ((&link_info)->hash))->dynamic_sections_created) |
| 740 | { |
| 741 | bfd *dynobj = elf_hash_table (&link_info)((struct elf_link_hash_table *) ((&link_info)->hash))->dynobj; |
| 742 | |
| 743 | if (dynobj != NULL((void*)0)) |
| 744 | { |
| 745 | asection *sec; |
| 746 | |
| 747 | sec = bfd_get_section_by_name (dynobj, ".got"); |
| 748 | if (sec) |
| 749 | sec->flags |= SEC_READONLY0x008; |
| 750 | } |
| 751 | |
| 752 | lang_for_each_input_file (gldelf_i386_force_readonly); |
| 753 | } |
| 754 | |
| 755 | /* Get the list of files which appear in DT_NEEDED entries in |
| 756 | dynamic objects included in the link (often there will be none). |
| 757 | For each such file, we want to track down the corresponding |
| 758 | library, and include the symbol table in the link. This is what |
| 759 | the runtime dynamic linker will do. Tracking the files down here |
| 760 | permits one dynamic object to include another without requiring |
| 761 | special action by the person doing the link. Note that the |
| 762 | needed list can actually grow while we are stepping through this |
| 763 | loop. */ |
| 764 | needed = bfd_elf_get_needed_list (output_bfd, &link_info); |
| 765 | for (l = needed; l != NULL((void*)0); l = l->next) |
| 766 | { |
| 767 | struct bfd_link_needed_list *ll; |
| 768 | struct dt_needed n, nn; |
| 769 | int force; |
| 770 | |
| 771 | /* If the lib that needs this one was --as-needed and wasn't |
| 772 | found to be needed, then this lib isn't needed either. */ |
| 773 | if (l->by != NULL((void*)0) |
| 774 | && (bfd_elf_get_dyn_lib_class (l->by) & DYN_AS_NEEDED) != 0) |
| 775 | continue; |
| 776 | |
| 777 | /* If we've already seen this file, skip it. */ |
| 778 | for (ll = needed; ll != l; ll = ll->next) |
| 779 | if ((ll->by == NULL((void*)0) |
| 780 | || (bfd_elf_get_dyn_lib_class (ll->by) & DYN_AS_NEEDED) == 0) |
| 781 | && strcmp (ll->name, l->name) == 0) |
| 782 | break; |
| 783 | if (ll != l) |
| 784 | continue; |
| 785 | |
| 786 | /* See if this file was included in the link explicitly. */ |
| 787 | global_needed = l; |
| 788 | global_found = NULL((void*)0); |
| 789 | lang_for_each_input_file (gldelf_i386_check_needed); |
| 790 | if (global_found != NULL((void*)0) |
| 791 | && (bfd_elf_get_dyn_lib_class (global_found->the_bfd) |
| 792 | & DYN_AS_NEEDED) == 0) |
| 793 | continue; |
| 794 | |
| 795 | n.by = l->by; |
| 796 | n.name = l->name; |
| 797 | nn.by = l->by; |
| 798 | if (trace_file_tries) |
| 799 | info_msg (_("%s needed by %B\n")("%s needed by %B\n"), l->name, l->by); |
| 800 | |
| 801 | /* As-needed libs specified on the command line (or linker script) |
| 802 | take priority over libs found in search dirs. */ |
| 803 | if (global_found != NULL((void*)0)) |
| 804 | { |
| 805 | nn.name = global_found->filename; |
| 806 | if (gldelf_i386_try_needed (&nn, TRUE1)) |
| 807 | continue; |
| 808 | } |
| 809 | |
| 810 | /* We need to find this file and include the symbol table. We |
| 811 | want to search for the file in the same way that the dynamic |
| 812 | linker will search. That means that we want to use |
| 813 | rpath_link, rpath, then the environment variable |
| 814 | LD_LIBRARY_PATH (native only), then the DT_RPATH/DT_RUNPATH |
| 815 | entries (native only), then the linker script LIB_SEARCH_DIRS. |
| 816 | We look at the -L arguments to build the search path. |
| 817 | |
| 818 | We search twice. The first time, we skip objects which may |
| 819 | introduce version mismatches. The second time, we force |
| 820 | their use. See gldelf_i386_vercheck comment. */ |
| 821 | for (force = 0; force < 2; force++) |
| 822 | { |
| 823 | size_t len; |
| 824 | search_dirs_type *search; |
| 825 | |
| 826 | if (gldelf_i386_search_needed (command_line.rpath_link, |
| 827 | &n, force)) |
| 828 | break; |
| 829 | len = strlen (l->name); |
| 830 | for (search = search_head; search != NULL((void*)0); search = search->next) |
| 831 | { |
| 832 | char *filename; |
| 833 | |
| 834 | if (search->cmdline) |
| 835 | continue; |
| 836 | filename = (char *) xmalloc (strlen (search->name) + len + 2); |
| 837 | sprintf (filename, "%s/%s", search->name, l->name); |
| 838 | nn.name = filename; |
| 839 | if (gldelf_i386_try_needed (&nn, force)) |
| 840 | break; |
| 841 | free (filename); |
| 842 | } |
| 843 | if (search != NULL((void*)0)) |
| 844 | break; |
| 845 | } |
| 846 | |
| 847 | if (force < 2) |
| 848 | continue; |
| 849 | |
| 850 | einfo ("%P: warning: %s, needed by %B, not found (try using -rpath or -rpath-link)\n", |
| 851 | l->name, l->by); |
| 852 | } |
| 853 | } |
| 854 | |
| 855 | |
| 856 | /* Look through an expression for an assignment statement. */ |
| 857 | |
| 858 | static void |
| 859 | gldelf_i386_find_exp_assignment (etree_type *exp) |
| 860 | { |
| 861 | bfd_boolean provide = FALSE0; |
| 862 | |
| 863 | switch (exp->type.node_class) |
| 864 | { |
| 865 | case etree_provide: |
| 866 | provide = TRUE1; |
| 867 | /* Fall thru */ |
| 868 | case etree_assign: |
| 869 | /* We call record_link_assignment even if the symbol is defined. |
| 870 | This is because if it is defined by a dynamic object, we |
| 871 | actually want to use the value defined by the linker script, |
| 872 | not the value from the dynamic object (because we are setting |
| 873 | symbols like etext). If the symbol is defined by a regular |
| 874 | object, then, as it happens, calling record_link_assignment |
| 875 | will do no harm. */ |
| 876 | if (strcmp (exp->assign.dst, ".") != 0) |
| 877 | { |
| 878 | if (!bfd_elf_record_link_assignment (output_bfd, &link_info, |
| 879 | exp->assign.dst, provide, |
| 880 | exp->assign.hidden)) |
| 881 | einfo ("%P%F: failed to record assignment to %s: %E\n", |
| 882 | exp->assign.dst); |
| 883 | } |
| 884 | gldelf_i386_find_exp_assignment (exp->assign.src); |
| 885 | break; |
| 886 | |
| 887 | case etree_binary: |
| 888 | gldelf_i386_find_exp_assignment (exp->binary.lhs); |
| 889 | gldelf_i386_find_exp_assignment (exp->binary.rhs); |
| 890 | break; |
| 891 | |
| 892 | case etree_trinary: |
| 893 | gldelf_i386_find_exp_assignment (exp->trinary.cond); |
| 894 | gldelf_i386_find_exp_assignment (exp->trinary.lhs); |
| 895 | gldelf_i386_find_exp_assignment (exp->trinary.rhs); |
| 896 | break; |
| 897 | |
| 898 | case etree_unary: |
| 899 | gldelf_i386_find_exp_assignment (exp->unary.child); |
| 900 | break; |
| 901 | |
| 902 | default: |
| 903 | break; |
| 904 | } |
| 905 | } |
| 906 | |
| 907 | |
| 908 | /* This is called by the before_allocation routine via |
| 909 | lang_for_each_statement. It locates any assignment statements, and |
| 910 | tells the ELF backend about them, in case they are assignments to |
| 911 | symbols which are referred to by dynamic objects. */ |
| 912 | |
| 913 | static void |
| 914 | gldelf_i386_find_statement_assignment (lang_statement_union_type *s) |
| 915 | { |
| 916 | if (s->header.type == lang_assignment_statement_enum) |
| 917 | gldelf_i386_find_exp_assignment (s->assignment_statement.exp); |
| 918 | } |
| 919 | |
| 920 | |
| 921 | /* This is called after the sections have been attached to output |
| 922 | sections, but before any sizes or addresses have been set. */ |
| 923 | |
| 924 | static void |
| 925 | gldelf_i386_before_allocation (void) |
| 926 | { |
| 927 | const char *rpath; |
| 928 | asection *sinterp; |
| 929 | |
| 930 | if (link_info.hash->type == bfd_link_elf_hash_table) |
| 931 | _bfd_elf_tls_setup (output_bfd, &link_info); |
| 932 | |
| 933 | /* If we are going to make any variable assignments, we need to let |
| 934 | the ELF backend know about them in case the variables are |
| 935 | referred to by dynamic objects. */ |
| 936 | lang_for_each_statement (gldelf_i386_find_statement_assignment); |
| 937 | |
| 938 | /* Let the ELF backend work out the sizes of any sections required |
| 939 | by dynamic linking. */ |
| 940 | rpath = command_line.rpath; |
| 941 | if (rpath == NULL((void*)0)) |
| 942 | rpath = (const char *) getenv ("LD_RUN_PATH"); |
| 943 | if (! (bfd_elf_size_dynamic_sections |
| 944 | (output_bfd, command_line.soname, rpath, |
| 945 | command_line.filter_shlib, |
| 946 | (const char * const *) command_line.auxiliary_filters, |
| 947 | &link_info, &sinterp, lang_elf_version_info))) |
| 948 | einfo ("%P%F: failed to set dynamic section sizes: %E\n"); |
| 949 | |
| 950 | |
| 951 | /* Let the user override the dynamic linker we are using. */ |
| 952 | if (command_line.interpreter != NULL((void*)0) |
| 953 | && sinterp != NULL((void*)0)) |
| 954 | { |
| 955 | sinterp->contents = (bfd_byte *) command_line.interpreter; |
| 956 | sinterp->size = strlen (command_line.interpreter) + 1; |
| 957 | } |
| 958 | |
| 959 | /* Look for any sections named .gnu.warning. As a GNU extensions, |
| 960 | we treat such sections as containing warning messages. We print |
| 961 | out the warning message, and then zero out the section size so |
| 962 | that it does not get copied into the output file. */ |
| 963 | |
| 964 | { |
| 965 | LANG_FOR_EACH_INPUT_STATEMENT (is)lang_input_statement_type *is; for (is = (lang_input_statement_type *) file_chain.head; is != (lang_input_statement_type *) ((void *)0); is = (lang_input_statement_type *) is->next) |
| 966 | { |
| 967 | asection *s; |
| 968 | bfd_size_type sz; |
| 969 | char *msg; |
| 970 | bfd_boolean ret; |
| 971 | |
| 972 | if (is->just_syms_flag) |
| 973 | continue; |
| 974 | |
| 975 | s = bfd_get_section_by_name (is->the_bfd, ".gnu.warning"); |
| 976 | if (s == NULL((void*)0)) |
| 977 | continue; |
| 978 | |
| 979 | sz = s->size; |
| 980 | msg = xmalloc ((size_t) (sz + 1)); |
| 981 | if (! bfd_get_section_contents (is->the_bfd, s, msg, (file_ptr) 0, sz)) |
| 982 | einfo ("%F%B: Can't read contents of section .gnu.warning: %E\n", |
| 983 | is->the_bfd); |
| 984 | msg[sz] = '\0'; |
| 985 | ret = link_info.callbacks->warning (&link_info, msg, |
| 986 | (const char *) NULL((void*)0), |
| 987 | is->the_bfd, (asection *) NULL((void*)0), |
| 988 | (bfd_vma) 0); |
| 989 | ASSERT (ret)do { if (!(ret)) info_assert("eelf_i386.c",989); } while (0); |
| 990 | free (msg); |
| 991 | |
| 992 | /* Clobber the section size, so that we don't waste copying the |
| 993 | warning into the output file. */ |
| 994 | s->size = 0; |
| 995 | |
| 996 | /* Also set SEC_EXCLUDE, so that symbols defined in the warning |
| 997 | section don't get copied to the output. */ |
| 998 | s->flags |= SEC_EXCLUDE0x8000; |
| 999 | } |
| 1000 | } |
| 1001 | |
| 1002 | before_allocation_default (); |
| 1003 | |
| 1004 | if (!bfd_elf_size_dynsym_hash_dynstr (output_bfd, &link_info)) |
| 1005 | einfo ("%P%F: failed to set dynamic section sizes: %E\n"); |
| 1006 | } |
| 1007 | |
| 1008 | |
| 1009 | /* Try to open a dynamic archive. This is where we know that ELF |
| 1010 | dynamic libraries have an extension of .so (or .sl on oddball systems |
| 1011 | like hpux). */ |
| 1012 | |
| 1013 | static bfd_boolean |
| 1014 | gldelf_i386_open_dynamic_archive |
| 1015 | (const char *arch __unused__attribute__((__unused__)), search_dirs_type *search, |
| 1016 | lang_input_statement_type *entry) |
| 1017 | { |
| 1018 | const char *filename; |
| 1019 | char *string; |
| 1020 | |
| 1021 | if (! entry->is_archive) |
| 1022 | return FALSE0; |
| 1023 | |
| 1024 | filename = entry->filename; |
| 1025 | |
| 1026 | string = gldelf_i386_search_dir(search->name, filename, -1, -1); |
| 1027 | if (string == NULL((void*)0)) |
| 1028 | return FALSE0; |
| 1029 | #ifdef EXTRA_SHLIB_EXTENSION |
| 1030 | /* Try the .so extension first. If that fails build a new filename |
| 1031 | using EXTRA_SHLIB_EXTENSION. */ |
| 1032 | if (! ldfile_try_open_bfd (string, entry)) |
| 1033 | sprintf (string, "%s/lib%s%s%s", search->name, |
| 1034 | filename, arch, EXTRA_SHLIB_EXTENSION); |
| 1035 | #endif |
| 1036 | |
| 1037 | if (! ldfile_try_open_bfd (string, entry)) |
| 1038 | { |
| 1039 | free (string); |
| 1040 | return FALSE0; |
| 1041 | } |
| 1042 | |
| 1043 | entry->filename = string; |
| 1044 | |
| 1045 | /* We have found a dynamic object to include in the link. The ELF |
| 1046 | backend linker will create a DT_NEEDED entry in the .dynamic |
| 1047 | section naming this file. If this file includes a DT_SONAME |
| 1048 | entry, it will be used. Otherwise, the ELF linker will just use |
| 1049 | the name of the file. For an archive found by searching, like |
| 1050 | this one, the DT_NEEDED entry should consist of just the name of |
| 1051 | the file, without the path information used to find it. Note |
| 1052 | that we only need to do this if we have a dynamic object; an |
| 1053 | archive will never be referenced by a DT_NEEDED entry. |
| 1054 | |
| 1055 | FIXME: This approach--using bfd_elf_set_dt_needed_name--is not |
| 1056 | very pretty. I haven't been able to think of anything that is |
| 1057 | pretty, though. */ |
| 1058 | if (bfd_check_format (entry->the_bfd, bfd_object) |
| 1059 | && (entry->the_bfd->flags & DYNAMIC0x40) != 0) |
| 1060 | { |
| 1061 | ASSERT (entry->is_archive && entry->search_dirs_flag)do { if (!(entry->is_archive && entry->search_dirs_flag )) info_assert("eelf_i386.c",1061); } while (0); |
| 1062 | |
| 1063 | /* Rather than duplicating the logic above. Just use the |
| 1064 | filename we recorded earlier. */ |
| 1065 | |
| 1066 | filename = lbasename (entry->filename); |
| 1067 | bfd_elf_set_dt_needed_name (entry->the_bfd, filename); |
| 1068 | } |
| 1069 | |
| 1070 | return TRUE1; |
| 1071 | } |
| 1072 | |
| 1073 | |
| 1074 | /* A variant of lang_output_section_find used by place_orphan. */ |
| 1075 | |
| 1076 | static lang_output_section_statement_type * |
| 1077 | output_rel_find (asection *sec, int isdyn) |
| 1078 | { |
| 1079 | lang_output_section_statement_type *lookup; |
| 1080 | lang_output_section_statement_type *last = NULL((void*)0); |
| 1081 | lang_output_section_statement_type *last_alloc = NULL((void*)0); |
| 1082 | lang_output_section_statement_type *last_rel = NULL((void*)0); |
| 1083 | lang_output_section_statement_type *last_rel_alloc = NULL((void*)0); |
| 1084 | int rela = sec->name[4] == 'a'; |
| 1085 | |
| 1086 | for (lookup = &lang_output_section_statement.head->output_section_statement; |
| 1087 | lookup != NULL((void*)0); |
| 1088 | lookup = lookup->next) |
| 1089 | { |
| 1090 | if (lookup->constraint != -1 |
| 1091 | && strncmp (".rel", lookup->name, 4) == 0) |
| 1092 | { |
| 1093 | int lookrela = lookup->name[4] == 'a'; |
| 1094 | |
| 1095 | /* .rel.dyn must come before all other reloc sections, to suit |
| 1096 | GNU ld.so. */ |
| 1097 | if (isdyn) |
| 1098 | break; |
| 1099 | |
| 1100 | /* Don't place after .rel.plt as doing so results in wrong |
| 1101 | dynamic tags. */ |
| 1102 | if (strcmp (".plt", lookup->name + 4 + lookrela) == 0) |
| 1103 | break; |
| 1104 | |
| 1105 | if (rela == lookrela || last_rel == NULL((void*)0)) |
| 1106 | last_rel = lookup; |
| 1107 | if ((rela == lookrela || last_rel_alloc == NULL((void*)0)) |
| 1108 | && lookup->bfd_section != NULL((void*)0) |
| 1109 | && (lookup->bfd_section->flags & SEC_ALLOC0x001) != 0) |
| 1110 | last_rel_alloc = lookup; |
| 1111 | } |
| 1112 | |
| 1113 | last = lookup; |
| 1114 | if (lookup->bfd_section != NULL((void*)0) |
| 1115 | && (lookup->bfd_section->flags & SEC_ALLOC0x001) != 0) |
| 1116 | last_alloc = lookup; |
| 1117 | } |
| 1118 | |
| 1119 | if (last_rel_alloc) |
| 1120 | return last_rel_alloc; |
| 1121 | |
| 1122 | if (last_rel) |
| 1123 | return last_rel; |
| 1124 | |
| 1125 | if (last_alloc) |
| 1126 | return last_alloc; |
| 1127 | |
| 1128 | return last; |
| 1129 | } |
| 1130 | |
| 1131 | /* Place an orphan section. We use this to put random SHF_ALLOC |
| 1132 | sections in the right segment. */ |
| 1133 | |
| 1134 | static bfd_boolean |
| 1135 | gldelf_i386_place_orphan (asection *s) |
| 1136 | { |
| 1137 | static struct orphan_save hold[] = |
| 1138 | { |
| 1139 | { ".text", |
| 1140 | SEC_HAS_CONTENTS0x100 | SEC_ALLOC0x001 | SEC_LOAD0x002 | SEC_READONLY0x008 | SEC_CODE0x010, |
| 1141 | 0, 0, 0, 0 }, |
| 1142 | { ".rodata", |
| 1143 | SEC_HAS_CONTENTS0x100 | SEC_ALLOC0x001 | SEC_LOAD0x002 | SEC_READONLY0x008 | SEC_DATA0x020, |
| 1144 | 0, 0, 0, 0 }, |
| 1145 | { ".data", |
| 1146 | SEC_HAS_CONTENTS0x100 | SEC_ALLOC0x001 | SEC_LOAD0x002 | SEC_DATA0x020, |
| 1147 | 0, 0, 0, 0 }, |
| 1148 | { ".bss", |
| 1149 | SEC_ALLOC0x001, |
| 1150 | 0, 0, 0, 0 }, |
| 1151 | { 0, |
| 1152 | SEC_HAS_CONTENTS0x100 | SEC_ALLOC0x001 | SEC_LOAD0x002 | SEC_READONLY0x008 | SEC_DATA0x020, |
| 1153 | 0, 0, 0, 0 }, |
| 1154 | { ".interp", |
| 1155 | SEC_HAS_CONTENTS0x100 | SEC_ALLOC0x001 | SEC_LOAD0x002 | SEC_READONLY0x008 | SEC_DATA0x020, |
| 1156 | 0, 0, 0, 0 }, |
| 1157 | { ".sdata", |
| 1158 | SEC_HAS_CONTENTS0x100 | SEC_ALLOC0x001 | SEC_LOAD0x002 | SEC_DATA0x020 | SEC_SMALL_DATA0x800000, |
| 1159 | 0, 0, 0, 0 } |
| 1160 | }; |
| 1161 | enum orphan_save_index |
| 1162 | { |
| 1163 | orphan_text = 0, |
| 1164 | orphan_rodata, |
| 1165 | orphan_data, |
| 1166 | orphan_bss, |
| 1167 | orphan_rel, |
| 1168 | orphan_interp, |
| 1169 | orphan_sdata |
| 1170 | }; |
| 1171 | static int orphan_init_done = 0; |
| 1172 | struct orphan_save *place; |
| 1173 | const char *secname; |
| 1174 | lang_output_section_statement_type *after; |
| 1175 | lang_output_section_statement_type *os; |
| 1176 | int isdyn = 0; |
| 1177 | int iself = s->owner->xvec->flavour == bfd_target_elf_flavour; |
| 1178 | unsigned int sh_type = iself ? elf_section_type (s)(((struct bfd_elf_section_data*)(s)->used_by_bfd)->this_hdr .sh_type) : SHT_NULL0; |
| 1179 | |
| 1180 | secname = bfd_get_section_name (s->owner, s)((s)->name + 0); |
| 1181 | |
| 1182 | if (! link_info.relocatable |
| 1183 | && link_info.combreloc |
| 1184 | && (s->flags & SEC_ALLOC0x001)) |
| 1185 | { |
| 1186 | if (iself) |
| 1187 | switch (sh_type) |
| 1188 | { |
| 1189 | case SHT_RELA4: |
| 1190 | secname = ".rela.dyn"; |
| 1191 | isdyn = 1; |
| 1192 | break; |
| 1193 | case SHT_REL9: |
| 1194 | secname = ".rel.dyn"; |
| 1195 | isdyn = 1; |
| 1196 | break; |
| 1197 | default: |
| 1198 | break; |
| 1199 | } |
| 1200 | else if (strncmp (secname, ".rel", 4) == 0) |
| 1201 | { |
| 1202 | secname = secname[4] == 'a' ? ".rela.dyn" : ".rel.dyn"; |
| 1203 | isdyn = 1; |
| 1204 | } |
| 1205 | } |
| 1206 | |
| 1207 | if (isdyn || (!config.unique_orphan_sections && !unique_section_p (s))) |
| 1208 | { |
| 1209 | /* Look through the script to see where to place this section. */ |
| 1210 | os = lang_output_section_find (secname); |
| 1211 | |
| 1212 | if (os != NULL((void*)0) |
| 1213 | && (os->bfd_section == NULL((void*)0) |
| 1214 | || os->bfd_section->flags == 0 |
| 1215 | || (_bfd_elf_match_sections_by_type (output_bfd, |
| 1216 | os->bfd_section, |
| 1217 | s->owner, s) |
| 1218 | && ((s->flags ^ os->bfd_section->flags) |
| 1219 | & (SEC_LOAD0x002 | SEC_ALLOC0x001)) == 0))) |
| 1220 | { |
| 1221 | /* We already have an output section statement with this |
| 1222 | name, and its bfd section, if any, has compatible flags. |
| 1223 | If the section already exists but does not have any flags |
| 1224 | set, then it has been created by the linker, probably as a |
| 1225 | result of a --section-start command line switch. */ |
| 1226 | lang_add_section (&os->children, s, os); |
| 1227 | return TRUE1; |
| 1228 | } |
| 1229 | } |
| 1230 | |
| 1231 | if (!orphan_init_done) |
| 1232 | { |
| 1233 | struct orphan_save *ho; |
| 1234 | for (ho = hold; ho < hold + sizeof (hold) / sizeof (hold[0]); ++ho) |
| 1235 | if (ho->name != NULL((void*)0)) |
| 1236 | { |
| 1237 | ho->os = lang_output_section_find (ho->name); |
| 1238 | if (ho->os != NULL((void*)0) && ho->os->flags == 0) |
| 1239 | ho->os->flags = ho->flags; |
| 1240 | } |
| 1241 | orphan_init_done = 1; |
| 1242 | } |
| 1243 | |
| 1244 | /* If this is a final link, then always put .gnu.warning.SYMBOL |
| 1245 | sections into the .text section to get them out of the way. */ |
| 1246 | if (link_info.executable |
| 1247 | && ! link_info.relocatable |
| 1248 | && strncmp (secname, ".gnu.warning.", sizeof ".gnu.warning." - 1) == 0 |
| 1249 | && hold[orphan_text].os != NULL((void*)0)) |
| 1250 | { |
| 1251 | lang_add_section (&hold[orphan_text].os->children, s, |
| 1252 | hold[orphan_text].os); |
| 1253 | return TRUE1; |
| 1254 | } |
| 1255 | |
| 1256 | /* Decide which segment the section should go in based on the |
| 1257 | section name and section flags. We put loadable .note sections |
| 1258 | right after the .interp section, so that the PT_NOTE segment is |
| 1259 | stored right after the program headers where the OS can read it |
| 1260 | in the first page. */ |
| 1261 | |
| 1262 | place = NULL((void*)0); |
| 1263 | if ((s->flags & SEC_ALLOC0x001) == 0) |
| 1264 | ; |
| 1265 | else if ((s->flags & SEC_LOAD0x002) != 0 |
| 1266 | && ((iself && sh_type == SHT_NOTE7) |
| 1267 | || (!iself && strncmp (secname, ".note", 5) == 0))) |
| 1268 | place = &hold[orphan_interp]; |
| 1269 | else if ((s->flags & (SEC_LOAD0x002 | SEC_HAS_CONTENTS0x100)) == 0) |
| 1270 | place = &hold[orphan_bss]; |
| 1271 | else if ((s->flags & SEC_SMALL_DATA0x800000) != 0) |
| 1272 | place = &hold[orphan_sdata]; |
| 1273 | else if ((s->flags & SEC_READONLY0x008) == 0) |
| 1274 | place = &hold[orphan_data]; |
| 1275 | else if (((iself && (sh_type == SHT_RELA4 || sh_type == SHT_REL9)) |
| 1276 | || (!iself && strncmp (secname, ".rel", 4) == 0)) |
| 1277 | && (s->flags & SEC_LOAD0x002) != 0) |
| 1278 | place = &hold[orphan_rel]; |
| 1279 | else if ((s->flags & SEC_CODE0x010) == 0) |
| 1280 | place = &hold[orphan_rodata]; |
| 1281 | else |
| 1282 | place = &hold[orphan_text]; |
| 1283 | |
| 1284 | after = NULL((void*)0); |
| 1285 | if (place != NULL((void*)0)) |
| 1286 | { |
| 1287 | if (place->os == NULL((void*)0)) |
| 1288 | { |
| 1289 | if (place->name != NULL((void*)0)) |
| 1290 | place->os = lang_output_section_find (place->name); |
| 1291 | else |
| 1292 | place->os = output_rel_find (s, isdyn); |
| 1293 | } |
| 1294 | after = place->os; |
| 1295 | if (after == NULL((void*)0)) |
| 1296 | after = lang_output_section_find_by_flags |
| 1297 | (s, &place->os, _bfd_elf_match_sections_by_type); |
| 1298 | if (after == NULL((void*)0)) |
| 1299 | /* *ABS* is always the first output section statement. */ |
| 1300 | after = &lang_output_section_statement.head->output_section_statement; |
| 1301 | } |
| 1302 | |
| 1303 | /* Choose a unique name for the section. This will be needed if the |
| 1304 | same section name appears in the input file with different |
| 1305 | loadable or allocatable characteristics. */ |
| 1306 | if (bfd_get_section_by_name (output_bfd, secname) != NULL((void*)0)) |
| 1307 | { |
| 1308 | static int count = 1; |
| 1309 | secname = bfd_get_unique_section_name (output_bfd, secname, &count); |
| 1310 | if (secname == NULL((void*)0)) |
| 1311 | einfo ("%F%P: place_orphan failed: %E\n"); |
| 1312 | } |
| 1313 | |
| 1314 | lang_insert_orphan (s, secname, after, place, NULL((void*)0), NULL((void*)0)); |
| 1315 | |
| 1316 | return TRUE1; |
| 1317 | } |
| 1318 | |
| 1319 | static void |
| 1320 | gldelf_i386_layout_sections_again (void) |
| 1321 | { |
| 1322 | lang_reset_memory_regions (); |
| 1323 | |
| 1324 | /* Resize the sections. */ |
| 1325 | lang_size_sections (NULL((void*)0), TRUE1); |
| 1326 | |
| 1327 | /* Redo special stuff. */ |
| 1328 | ldemul_after_allocation (); |
| 1329 | |
| 1330 | /* Do the assignments again. */ |
| 1331 | lang_do_assignments (); |
| 1332 | } |
| 1333 | |
| 1334 | static void |
| 1335 | gldelf_i386_finish (void) |
| 1336 | { |
| 1337 | if (bfd_elf_discard_info (output_bfd, &link_info)) |
| 1338 | gldelf_i386_layout_sections_again (); |
| 1339 | |
| 1340 | finish_default (); |
| 1341 | } |
| 1342 | |
| 1343 | static char * |
| 1344 | gldelf_i386_get_script (int *isfile) |
| 1345 | { |
| 1346 | *isfile = 1; |
| 1347 | |
| 1348 | if (link_info.relocatable && config.build_constructors) |
| 1349 | return "ldscripts/elf_i386.xu"; |
| 1350 | else if (link_info.relocatable) |
| 1351 | return "ldscripts/elf_i386.xr"; |
| 1352 | else if (!config.text_read_only) |
| 1353 | return "ldscripts/elf_i386.xbn"; |
| 1354 | else if (!config.magic_demand_paged) |
| 1355 | return "ldscripts/elf_i386.xn"; |
| 1356 | else if (link_info.pie && link_info.combreloc && link_info.relro) |
| 1357 | return "ldscripts/elf_i386.xdw"; |
| 1358 | else if (link_info.pie && link_info.combreloc && config.data_bss_contig == TRUE1) |
| 1359 | return "ldscripts/elf_i386.xdcz"; |
| 1360 | else if (link_info.pie && link_info.combreloc) |
| 1361 | return "ldscripts/elf_i386.xdc"; |
| 1362 | else if (link_info.pie && config.data_bss_contig == TRUE1) |
| 1363 | return "ldscripts/elf_i386.xdz"; |
| 1364 | else if (link_info.pie) |
| 1365 | return "ldscripts/elf_i386.xd"; |
| 1366 | else if (link_info.shared && link_info.combreloc && link_info.relro) |
| 1367 | return "ldscripts/elf_i386.xsw"; |
| 1368 | else if (link_info.shared && link_info.combreloc) |
| 1369 | return "ldscripts/elf_i386.xsc"; |
| 1370 | else if (link_info.shared) |
| 1371 | return "ldscripts/elf_i386.xs"; |
| 1372 | else if (config.data_bss_contig == TRUE1) |
| 1373 | return "ldscripts/elf_i386.xz"; |
| 1374 | else if (link_info.combreloc && link_info.relro) |
| 1375 | return "ldscripts/elf_i386.xw"; |
| 1376 | else if (link_info.combreloc) |
| 1377 | return "ldscripts/elf_i386.xc"; |
| 1378 | else |
| 1379 | return "ldscripts/elf_i386.x"; |
| 1380 | } |
| 1381 | |
| 1382 | |
| 1383 | #define OPTION_DISABLE_NEW_DTAGS(400) (400) |
| 1384 | #define OPTION_ENABLE_NEW_DTAGS((400) + 1) (OPTION_DISABLE_NEW_DTAGS(400) + 1) |
| 1385 | #define OPTION_GROUP(((400) + 1) + 1) (OPTION_ENABLE_NEW_DTAGS((400) + 1) + 1) |
| 1386 | #define OPTION_EH_FRAME_HDR((((400) + 1) + 1) + 1) (OPTION_GROUP(((400) + 1) + 1) + 1) |
| 1387 | #define OPTION_EXCLUDE_LIBS(((((400) + 1) + 1) + 1) + 1) (OPTION_EH_FRAME_HDR((((400) + 1) + 1) + 1) + 1) |
| 1388 | #define OPTION_HASH_STYLE((((((400) + 1) + 1) + 1) + 1) + 1) (OPTION_EXCLUDE_LIBS(((((400) + 1) + 1) + 1) + 1) + 1) |
| 1389 | |
| 1390 | static void |
| 1391 | gldelf_i386_add_options |
| 1392 | (int ns, char **shortopts, int nl, struct option **longopts, |
| 1393 | int nrl ATTRIBUTE_UNUSED__attribute__ ((__unused__)), struct option **really_longopts ATTRIBUTE_UNUSED__attribute__ ((__unused__))) |
| 1394 | { |
| 1395 | static const char xtra_short[] = "z:"; |
| 1396 | static const struct option xtra_long[] = { |
| 1397 | {"disable-new-dtags", no_argument0, NULL((void*)0), OPTION_DISABLE_NEW_DTAGS(400)}, |
| 1398 | {"enable-new-dtags", no_argument0, NULL((void*)0), OPTION_ENABLE_NEW_DTAGS((400) + 1)}, |
| 1399 | {"eh-frame-hdr", no_argument0, NULL((void*)0), OPTION_EH_FRAME_HDR((((400) + 1) + 1) + 1)}, |
| 1400 | {"exclude-libs", required_argument1, NULL((void*)0), OPTION_EXCLUDE_LIBS(((((400) + 1) + 1) + 1) + 1)}, |
| 1401 | {"hash-style", required_argument1, NULL((void*)0), OPTION_HASH_STYLE((((((400) + 1) + 1) + 1) + 1) + 1)}, |
| 1402 | {"Bgroup", no_argument0, NULL((void*)0), OPTION_GROUP(((400) + 1) + 1)}, |
| 1403 | {NULL((void*)0), no_argument0, NULL((void*)0), 0} |
| 1404 | }; |
| 1405 | |
| 1406 | *shortopts = (char *) xrealloc (*shortopts, ns + sizeof (xtra_short)); |
| 1407 | memcpy (*shortopts + ns, &xtra_short, sizeof (xtra_short)); |
| 1408 | *longopts = (struct option *) |
| 1409 | xrealloc (*longopts, nl * sizeof (struct option) + sizeof (xtra_long)); |
| 1410 | memcpy (*longopts + nl, &xtra_long, sizeof (xtra_long)); |
| 1411 | } |
| 1412 | |
| 1413 | static bfd_boolean |
| 1414 | gldelf_i386_handle_option (int optc) |
| 1415 | { |
| 1416 | switch (optc) |
| 1417 | { |
| 1418 | default: |
| 1419 | return FALSE0; |
| 1420 | |
| 1421 | case OPTION_DISABLE_NEW_DTAGS(400): |
| 1422 | link_info.new_dtags = FALSE0; |
| 1423 | break; |
| 1424 | |
| 1425 | case OPTION_ENABLE_NEW_DTAGS((400) + 1): |
| 1426 | link_info.new_dtags = TRUE1; |
| 1427 | break; |
| 1428 | |
| 1429 | case OPTION_EH_FRAME_HDR((((400) + 1) + 1) + 1): |
| 1430 | link_info.eh_frame_hdr = TRUE1; |
| 1431 | break; |
| 1432 | |
| 1433 | case OPTION_GROUP(((400) + 1) + 1): |
| 1434 | link_info.flags_1 |= (bfd_vma) DF_1_GROUP0x00000004; |
| 1435 | /* Groups must be self-contained. */ |
| 1436 | link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR; |
| 1437 | link_info.unresolved_syms_in_shared_libs = RM_GENERATE_ERROR; |
| 1438 | break; |
| 1439 | |
| 1440 | case OPTION_EXCLUDE_LIBS(((((400) + 1) + 1) + 1) + 1): |
| 1441 | add_excluded_libs (optarg); |
| 1442 | break; |
| 1443 | |
| 1444 | case OPTION_HASH_STYLE((((((400) + 1) + 1) + 1) + 1) + 1): |
| 1445 | #ifndef __mips64__ |
| 1446 | link_info.emit_hash = FALSE0; |
| 1447 | link_info.emit_gnu_hash = FALSE0; |
| 1448 | if (strcmp (optarg, "sysv") == 0) |
| 1449 | link_info.emit_hash = TRUE1; |
| 1450 | else if (strcmp (optarg, "gnu") == 0) |
| 1451 | link_info.emit_gnu_hash = TRUE1; |
| 1452 | else if (strcmp (optarg, "both") == 0) |
| 1453 | { |
| 1454 | link_info.emit_hash = TRUE1; |
| 1455 | link_info.emit_gnu_hash = TRUE1; |
| 1456 | } |
| 1457 | else |
| 1458 | einfo (_("%P%F: invalid hash style `%s'\n")("%P%F: invalid hash style `%s'\n"), optarg); |
| 1459 | #endif |
| 1460 | break; |
| 1461 | |
| 1462 | case 'z': |
| 1463 | if (strcmp (optarg, "initfirst") == 0) |
| 1464 | link_info.flags_1 |= (bfd_vma) DF_1_INITFIRST0x00000020; |
| 1465 | else if (strcmp (optarg, "interpose") == 0) |
| 1466 | link_info.flags_1 |= (bfd_vma) DF_1_INTERPOSE0x00000400; |
| 1467 | else if (strcmp (optarg, "loadfltr") == 0) |
| 1468 | link_info.flags_1 |= (bfd_vma) DF_1_LOADFLTR0x00000010; |
| 1469 | else if (strcmp (optarg, "nodefaultlib") == 0) |
| 1470 | link_info.flags_1 |= (bfd_vma) DF_1_NODEFLIB0x00000800; |
| 1471 | else if (strcmp (optarg, "nodelete") == 0) |
| 1472 | link_info.flags_1 |= (bfd_vma) DF_1_NODELETE0x00000008; |
| 1473 | else if (strcmp (optarg, "nodlopen") == 0) |
| 1474 | link_info.flags_1 |= (bfd_vma) DF_1_NOOPEN0x00000040; |
| 1475 | else if (strcmp (optarg, "nodump") == 0) |
| 1476 | link_info.flags_1 |= (bfd_vma) DF_1_NODUMP0x00001000; |
| 1477 | else if (strcmp (optarg, "now") == 0) |
| 1478 | { |
| 1479 | link_info.flags |= (bfd_vma) DF_BIND_NOW(1 << 3); |
| 1480 | link_info.flags_1 |= (bfd_vma) DF_1_NOW0x00000001; |
| 1481 | } |
| 1482 | else if (strcmp (optarg, "origin") == 0) |
| 1483 | { |
| 1484 | link_info.flags |= (bfd_vma) DF_ORIGIN(1 << 0); |
| 1485 | link_info.flags_1 |= (bfd_vma) DF_1_ORIGIN0x00000080; |
| 1486 | } |
| 1487 | else if (strcmp (optarg, "defs") == 0) |
| 1488 | link_info.unresolved_syms_in_objects = RM_GENERATE_ERROR; |
| 1489 | else if (strcmp (optarg, "muldefs") == 0) |
| 1490 | link_info.allow_multiple_definition = TRUE1; |
| 1491 | else if (strcmp (optarg, "combreloc") == 0) |
| 1492 | link_info.combreloc = TRUE1; |
| 1493 | else if (strcmp (optarg, "nocombreloc") == 0) |
| 1494 | link_info.combreloc = FALSE0; |
| 1495 | else if (strcmp (optarg, "nocopyreloc") == 0) |
| 1496 | link_info.nocopyreloc = TRUE1; |
| 1497 | else if (strcmp (optarg, "execstack") == 0) |
| 1498 | { |
| 1499 | link_info.execstack = TRUE1; |
| 1500 | link_info.noexecstack = FALSE0; |
| 1501 | } |
| 1502 | else if (strcmp (optarg, "noexecstack") == 0) |
| 1503 | { |
| 1504 | link_info.noexecstack = TRUE1; |
| 1505 | link_info.execstack = FALSE0; |
| 1506 | } |
| 1507 | else if (strcmp (optarg, "relro") == 0) |
| 1508 | link_info.relro = TRUE1; |
| 1509 | else if (strcmp (optarg, "norelro") == 0) |
| 1510 | link_info.relro = FALSE0; |
| 1511 | else if (strcmp (optarg, "wxneeded") == 0) |
| 1512 | link_info.wxneeded = TRUE1; |
| 1513 | else if (strcmp (optarg, "notext") == 0) |
| 1514 | link_info.allow_textrel = TRUE1; |
| 1515 | else if (strcmp (optarg, "text") == 0) |
| 1516 | link_info.allow_textrel = FALSE0; |
| 1517 | /* What about the other Solaris -z options? FIXME. */ |
| 1518 | break; |
| 1519 | } |
| 1520 | |
| 1521 | return TRUE1; |
| 1522 | } |
| 1523 | |
| 1524 | |
| 1525 | static void |
| 1526 | gldelf_i386_list_options (FILE * file) |
| 1527 | { |
| 1528 | fprintf (file, _(" -Bgroup\t\tSelects group name lookup rules for DSO\n")(" -Bgroup\t\tSelects group name lookup rules for DSO\n")); |
| 1529 | fprintf (file, _(" --disable-new-dtags\tDisable new dynamic tags\n")(" --disable-new-dtags\tDisable new dynamic tags\n")); |
| 1530 | fprintf (file, _(" --enable-new-dtags\tEnable new dynamic tags\n")(" --enable-new-dtags\tEnable new dynamic tags\n")); |
| 1531 | fprintf (file, _(" --eh-frame-hdr\tCreate .eh_frame_hdr section\n")(" --eh-frame-hdr\tCreate .eh_frame_hdr section\n")); |
| 1532 | fprintf (file, _(" --hash-style=STYLE\tSet hash style to sysv, gnu or both\n")(" --hash-style=STYLE\tSet hash style to sysv, gnu or both\n" )); |
| 1533 | fprintf (file, _(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n")(" -z combreloc\t\tMerge dynamic relocs into one section and sort\n" )); |
| 1534 | fprintf (file, _(" -z defs\t\tReport unresolved symbols in object files.\n")(" -z defs\t\tReport unresolved symbols in object files.\n")); |
| 1535 | fprintf (file, _(" -z execstack\t\tMark executable as requiring executable stack\n")(" -z execstack\t\tMark executable as requiring executable stack\n" )); |
| 1536 | fprintf (file, _(" -z initfirst\t\tMark DSO to be initialized first at runtime\n")(" -z initfirst\t\tMark DSO to be initialized first at runtime\n" )); |
| 1537 | fprintf (file, _(" -z interpose\t\tMark object to interpose all DSOs but executable\n")(" -z interpose\t\tMark object to interpose all DSOs but executable\n" )); |
| 1538 | fprintf (file, _(" -z loadfltr\t\tMark object requiring immediate process\n")(" -z loadfltr\t\tMark object requiring immediate process\n" )); |
| 1539 | fprintf (file, _(" -z muldefs\t\tAllow multiple definitions\n")(" -z muldefs\t\tAllow multiple definitions\n")); |
| 1540 | fprintf (file, _(" -z nocombreloc\tDon't merge dynamic relocs into one section\n")(" -z nocombreloc\tDon't merge dynamic relocs into one section\n" )); |
| 1541 | fprintf (file, _(" -z nocopyreloc\tDon't create copy relocs\n")(" -z nocopyreloc\tDon't create copy relocs\n")); |
| 1542 | fprintf (file, _(" -z nodefaultlib\tMark object not to use default search paths\n")(" -z nodefaultlib\tMark object not to use default search paths\n" )); |
| 1543 | fprintf (file, _(" -z nodelete\t\tMark DSO non-deletable at runtime\n")(" -z nodelete\t\tMark DSO non-deletable at runtime\n")); |
| 1544 | fprintf (file, _(" -z nodlopen\t\tMark DSO not available to dlopen\n")(" -z nodlopen\t\tMark DSO not available to dlopen\n")); |
| 1545 | fprintf (file, _(" -z nodump\t\tMark DSO not available to dldump\n")(" -z nodump\t\tMark DSO not available to dldump\n")); |
| 1546 | fprintf (file, _(" -z noexecstack\tMark executable as not requiring executable stack\n")(" -z noexecstack\tMark executable as not requiring executable stack\n" )); |
| 1547 | fprintf (file, _(" -z norelro\t\tDon't create RELRO program header\n")(" -z norelro\t\tDon't create RELRO program header\n")); |
| 1548 | fprintf (file, _(" -z now\t\tMark object non-lazy runtime binding\n")(" -z now\t\tMark object non-lazy runtime binding\n")); |
| 1549 | fprintf (file, _(" -z origin\t\tMark object requiring immediate $ORIGIN processing\n\t\t\t at runtime\n")(" -z origin\t\tMark object requiring immediate $ORIGIN processing\n\t\t\t at runtime\n" )); |
| 1550 | fprintf (file, _(" -z relro\t\tCreate RELRO program header\n")(" -z relro\t\tCreate RELRO program header\n")); |
| 1551 | fprintf (file, _(" -z KEYWORD\t\tIgnored for Solaris compatibility\n")(" -z KEYWORD\t\tIgnored for Solaris compatibility\n")); |
| 1552 | } |
| 1553 | |
| 1554 | struct ld_emulation_xfer_struct ld_elf_i386_emulation = |
| 1555 | { |
| 1556 | gldelf_i386_before_parse, |
| 1557 | syslib_default, |
| 1558 | hll_default, |
| 1559 | after_parse_default, |
| 1560 | gldelf_i386_after_open, |
| 1561 | after_allocation_default, |
| 1562 | set_output_arch_default, |
| 1563 | ldemul_default_target, |
| 1564 | gldelf_i386_before_allocation, |
| 1565 | gldelf_i386_get_script, |
| 1566 | "elf_i386", |
| 1567 | "elf32-i386", |
| 1568 | gldelf_i386_finish, |
| 1569 | NULL((void*)0), |
| 1570 | gldelf_i386_open_dynamic_archive, |
| 1571 | gldelf_i386_place_orphan, |
| 1572 | NULL((void*)0), |
| 1573 | NULL((void*)0), |
| 1574 | gldelf_i386_add_options, |
| 1575 | gldelf_i386_handle_option, |
| 1576 | NULL((void*)0), |
| 1577 | gldelf_i386_list_options, |
| 1578 | gldelf_i386_load_symbols, |
| 1579 | NULL((void*)0), |
| 1580 | NULL((void*)0) |
| 1581 | }; |