Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: bfd/elf32-score.c

Issue 11969036: Merge GDB 7.5.1 (Closed) Base URL: http://git.chromium.org/native_client/nacl-gdb.git@master
Patch Set: Created 7 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « bfd/elf32-s390.c ('k') | bfd/elf32-score7.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 32-bit ELF support for S+core. 1 /* 32-bit ELF support for S+core.
2 Copyright 2006, 2007, 2008, 2009, 2010, 2011 2 Copyright 2006, 2007, 2008, 2009, 2010, 2011, 2012
3 Free Software Foundation, Inc. 3 Free Software Foundation, Inc.
4 Contributed by 4 Contributed by
5 Brain.lin (brain.lin@sunplusct.com) 5 Brain.lin (brain.lin@sunplusct.com)
6 Mei Ligang (ligang@sunnorth.com.cn) 6 Mei Ligang (ligang@sunnorth.com.cn)
7 Pei-Lin Tsai (pltsai@sunplus.com) 7 Pei-Lin Tsai (pltsai@sunplus.com)
8 8
9 This file is part of BFD, the Binary File Descriptor library. 9 This file is part of BFD, the Binary File Descriptor library.
10 10
11 This program is free software; you can redistribute it and/or modify 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 12 it under the terms of the GNU General Public License as published by
(...skipping 1046 matching lines...) Expand 10 before | Expand all | Expand 10 after
1059 h->root.dynindx = --hsd->min_got_dynindx; 1059 h->root.dynindx = --hsd->min_got_dynindx;
1060 hsd->low = (struct elf_link_hash_entry *) h; 1060 hsd->low = (struct elf_link_hash_entry *) h;
1061 } 1061 }
1062 1062
1063 return TRUE; 1063 return TRUE;
1064 } 1064 }
1065 1065
1066 static asection * 1066 static asection *
1067 score_elf_got_section (bfd *abfd, bfd_boolean maybe_excluded) 1067 score_elf_got_section (bfd *abfd, bfd_boolean maybe_excluded)
1068 { 1068 {
1069 asection *sgot = bfd_get_section_by_name (abfd, ".got"); 1069 asection *sgot = bfd_get_linker_section (abfd, ".got");
1070 1070
1071 if (sgot == NULL || (! maybe_excluded && (sgot->flags & SEC_EXCLUDE) != 0)) 1071 if (sgot == NULL || (! maybe_excluded && (sgot->flags & SEC_EXCLUDE) != 0))
1072 return NULL; 1072 return NULL;
1073 return sgot; 1073 return sgot;
1074 } 1074 }
1075 1075
1076 /* Returns the GOT information associated with the link indicated by 1076 /* Returns the GOT information associated with the link indicated by
1077 INFO. If SGOTP is non-NULL, it is filled in with the GOT section. */ 1077 INFO. If SGOTP is non-NULL, it is filled in with the GOT section. */
1078 static struct score_got_info * 1078 static struct score_got_info *
1079 score_elf_got_info (bfd *abfd, asection **sgotp) 1079 score_elf_got_info (bfd *abfd, asection **sgotp)
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1240 return FALSE; 1240 return FALSE;
1241 } 1241 }
1242 1242
1243 /* Returns the dynamic relocation section for DYNOBJ. */ 1243 /* Returns the dynamic relocation section for DYNOBJ. */
1244 static asection * 1244 static asection *
1245 score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p) 1245 score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p)
1246 { 1246 {
1247 static const char dname[] = ".rel.dyn"; 1247 static const char dname[] = ".rel.dyn";
1248 asection *sreloc; 1248 asection *sreloc;
1249 1249
1250 sreloc = bfd_get_section_by_name (dynobj, dname); 1250 sreloc = bfd_get_linker_section (dynobj, dname);
1251 if (sreloc == NULL && create_p) 1251 if (sreloc == NULL && create_p)
1252 { 1252 {
1253 sreloc = bfd_make_section_with_flags (dynobj, dname, 1253 sreloc = bfd_make_section_anyway_with_flags (dynobj, dname,
1254 (SEC_ALLOC 1254 » » » » » » (SEC_ALLOC
1255 | SEC_LOAD 1255 » » » » » » | SEC_LOAD
1256 | SEC_HAS_CONTENTS 1256 » » » » » » | SEC_HAS_CONTENTS
1257 | SEC_IN_MEMORY 1257 » » » » » » | SEC_IN_MEMORY
1258 | SEC_LINKER_CREATED 1258 » » » » » » | SEC_LINKER_CREATED
1259 | SEC_READONLY)); 1259 » » » » » » | SEC_READONLY));
1260 if (sreloc == NULL 1260 if (sreloc == NULL
1261 || ! bfd_set_section_alignment (dynobj, sreloc, 1261 || ! bfd_set_section_alignment (dynobj, sreloc,
1262 SCORE_ELF_LOG_FILE_ALIGN (dynobj))) 1262 SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
1263 return NULL; 1263 return NULL;
1264 } 1264 }
1265 return sreloc; 1265 return sreloc;
1266 } 1266 }
1267 1267
1268 static void 1268 static void
1269 score_elf_allocate_dynamic_relocations (bfd *abfd, unsigned int n) 1269 score_elf_allocate_dynamic_relocations (bfd *abfd, unsigned int n)
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1422 return TRUE; 1422 return TRUE;
1423 } 1423 }
1424 1424
1425 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_ CREATED); 1425 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_ CREATED);
1426 1426
1427 if (maybe_exclude) 1427 if (maybe_exclude)
1428 flags |= SEC_EXCLUDE; 1428 flags |= SEC_EXCLUDE;
1429 1429
1430 /* We have to use an alignment of 2**4 here because this is hardcoded 1430 /* We have to use an alignment of 2**4 here because this is hardcoded
1431 in the function stub generation and in the linker script. */ 1431 in the function stub generation and in the linker script. */
1432 s = bfd_make_section_with_flags (abfd, ".got", flags); 1432 s = bfd_make_section_anyway_with_flags (abfd, ".got", flags);
1433 if (s == NULL 1433 if (s == NULL
1434 || ! bfd_set_section_alignment (abfd, s, 4)) 1434 || ! bfd_set_section_alignment (abfd, s, 4))
1435 return FALSE; 1435 return FALSE;
1436 1436
1437 /* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the 1437 /* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the
1438 linker script because we don't want to define the symbol if we 1438 linker script because we don't want to define the symbol if we
1439 are not creating a global offset table. */ 1439 are not creating a global offset table. */
1440 bh = NULL; 1440 bh = NULL;
1441 if (! (_bfd_generic_link_add_one_symbol 1441 if (! (_bfd_generic_link_add_one_symbol
1442 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s, 1442 (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
(...skipping 1222 matching lines...) Expand 10 before | Expand all | Expand 10 after
2665 if (! ((*info->callbacks->undefined_symbol) 2665 if (! ((*info->callbacks->undefined_symbol)
2666 (info, h->root.root.root.string, input_bfd, 2666 (info, h->root.root.root.string, input_bfd,
2667 input_section, rel->r_offset, 2667 input_section, rel->r_offset,
2668 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR) 2668 (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
2669 || ELF_ST_VISIBILITY (h->root.other)))) 2669 || ELF_ST_VISIBILITY (h->root.other))))
2670 return bfd_reloc_undefined; 2670 return bfd_reloc_undefined;
2671 relocation = 0; 2671 relocation = 0;
2672 } 2672 }
2673 } 2673 }
2674 2674
2675 if (sec != NULL && elf_discarded_section (sec)) 2675 if (sec != NULL && discarded_section (sec))
2676 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section, 2676 RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
2677 » » » » » rel, relend, howto, contents); 2677 » » » » » rel, 1, relend, howto, 0, contents);
2678 2678
2679 if (info->relocatable) 2679 if (info->relocatable)
2680 { 2680 {
2681 /* This is a relocatable link. We don't have to change 2681 /* This is a relocatable link. We don't have to change
2682 anything, unless the reloc is against a section symbol, 2682 anything, unless the reloc is against a section symbol,
2683 in which case we have to adjust according to where the 2683 in which case we have to adjust according to where the
2684 section symbol winds up in the output section. */ 2684 section symbol winds up in the output section. */
2685 if (r_symndx < symtab_hdr->sh_info) 2685 if (r_symndx < symtab_hdr->sh_info)
2686 { 2686 {
2687 sym = local_syms + r_symndx; 2687 sym = local_syms + r_symndx;
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
3116 if (!elf_hash_table (info)->dynamic_sections_created) 3116 if (!elf_hash_table (info)->dynamic_sections_created)
3117 return TRUE; 3117 return TRUE;
3118 3118
3119 /* If this symbol is not defined in a regular file, then set 3119 /* If this symbol is not defined in a regular file, then set
3120 the symbol to the stub location. This is required to make 3120 the symbol to the stub location. This is required to make
3121 function pointers compare as equal between the normal 3121 function pointers compare as equal between the normal
3122 executable and the shared library. */ 3122 executable and the shared library. */
3123 if (!h->def_regular) 3123 if (!h->def_regular)
3124 { 3124 {
3125 /* We need .stub section. */ 3125 /* We need .stub section. */
3126 s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME); 3126 s = bfd_get_linker_section (dynobj, SCORE_ELF_STUB_SECTION_NAME);
3127 BFD_ASSERT (s != NULL); 3127 BFD_ASSERT (s != NULL);
3128 3128
3129 h->root.u.def.section = s; 3129 h->root.u.def.section = s;
3130 h->root.u.def.value = s->size; 3130 h->root.u.def.value = s->size;
3131 3131
3132 /* XXX Write this stub address somewhere. */ 3132 /* XXX Write this stub address somewhere. */
3133 h->plt.offset = s->size; 3133 h->plt.offset = s->size;
3134 3134
3135 /* Make room for this stub code. */ 3135 /* Make room for this stub code. */
3136 s->size += SCORE_FUNCTION_STUB_SIZE; 3136 s->size += SCORE_FUNCTION_STUB_SIZE;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
3252 bfd_boolean reltext; 3252 bfd_boolean reltext;
3253 3253
3254 dynobj = elf_hash_table (info)->dynobj; 3254 dynobj = elf_hash_table (info)->dynobj;
3255 BFD_ASSERT (dynobj != NULL); 3255 BFD_ASSERT (dynobj != NULL);
3256 3256
3257 if (elf_hash_table (info)->dynamic_sections_created) 3257 if (elf_hash_table (info)->dynamic_sections_created)
3258 { 3258 {
3259 /* Set the contents of the .interp section to the interpreter. */ 3259 /* Set the contents of the .interp section to the interpreter. */
3260 if (!info->shared) 3260 if (!info->shared)
3261 { 3261 {
3262 s = bfd_get_section_by_name (dynobj, ".interp"); 3262 s = bfd_get_linker_section (dynobj, ".interp");
3263 BFD_ASSERT (s != NULL); 3263 BFD_ASSERT (s != NULL);
3264 s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1; 3264 s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
3265 s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER; 3265 s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
3266 } 3266 }
3267 } 3267 }
3268 3268
3269 /* The check_relocs and adjust_dynamic_symbol entry points have 3269 /* The check_relocs and adjust_dynamic_symbol entry points have
3270 determined the sizes of the various dynamic sections. Allocate 3270 determined the sizes of the various dynamic sections. Allocate
3271 memory for them. */ 3271 memory for them. */
3272 reltext = FALSE; 3272 reltext = FALSE;
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
3410 { 3410 {
3411 struct elf_link_hash_entry *h; 3411 struct elf_link_hash_entry *h;
3412 struct bfd_link_hash_entry *bh; 3412 struct bfd_link_hash_entry *bh;
3413 flagword flags; 3413 flagword flags;
3414 asection *s; 3414 asection *s;
3415 3415
3416 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY 3416 flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
3417 | SEC_LINKER_CREATED | SEC_READONLY); 3417 | SEC_LINKER_CREATED | SEC_READONLY);
3418 3418
3419 /* ABI requests the .dynamic section to be read only. */ 3419 /* ABI requests the .dynamic section to be read only. */
3420 s = bfd_get_section_by_name (abfd, ".dynamic"); 3420 s = bfd_get_linker_section (abfd, ".dynamic");
3421 if (s != NULL) 3421 if (s != NULL)
3422 { 3422 {
3423 if (!bfd_set_section_flags (abfd, s, flags)) 3423 if (!bfd_set_section_flags (abfd, s, flags))
3424 return FALSE; 3424 return FALSE;
3425 } 3425 }
3426 3426
3427 /* We need to create .got section. */ 3427 /* We need to create .got section. */
3428 if (!score_elf_create_got_section (abfd, info, FALSE)) 3428 if (!score_elf_create_got_section (abfd, info, FALSE))
3429 return FALSE; 3429 return FALSE;
3430 3430
3431 if (!score_elf_rel_dyn_section (elf_hash_table (info)->dynobj, TRUE)) 3431 if (!score_elf_rel_dyn_section (elf_hash_table (info)->dynobj, TRUE))
3432 return FALSE; 3432 return FALSE;
3433 3433
3434 /* Create .stub section. */ 3434 /* Create .stub section. */
3435 if (bfd_get_section_by_name (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL) 3435 if (bfd_get_linker_section (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
3436 { 3436 {
3437 s = bfd_make_section_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME, 3437 s = bfd_make_section_anyway_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
3438 flags | SEC_CODE); 3438 » » » » » flags | SEC_CODE);
3439 if (s == NULL 3439 if (s == NULL
3440 || !bfd_set_section_alignment (abfd, s, 2)) 3440 || !bfd_set_section_alignment (abfd, s, 2))
3441 3441
3442 return FALSE; 3442 return FALSE;
3443 } 3443 }
3444 3444
3445 if (!info->shared) 3445 if (!info->shared)
3446 { 3446 {
3447 const char *name; 3447 const char *name;
3448 3448
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3482 dynobj = elf_hash_table (info)->dynobj; 3482 dynobj = elf_hash_table (info)->dynobj;
3483 3483
3484 if (h->plt.offset != MINUS_ONE) 3484 if (h->plt.offset != MINUS_ONE)
3485 { 3485 {
3486 asection *s; 3486 asection *s;
3487 bfd_byte stub[SCORE_FUNCTION_STUB_SIZE]; 3487 bfd_byte stub[SCORE_FUNCTION_STUB_SIZE];
3488 3488
3489 /* This symbol has a stub. Set it up. */ 3489 /* This symbol has a stub. Set it up. */
3490 BFD_ASSERT (h->dynindx != -1); 3490 BFD_ASSERT (h->dynindx != -1);
3491 3491
3492 s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME); 3492 s = bfd_get_linker_section (dynobj, SCORE_ELF_STUB_SECTION_NAME);
3493 BFD_ASSERT (s != NULL); 3493 BFD_ASSERT (s != NULL);
3494 3494
3495 /* FIXME: Can h->dynindex be more than 64K? */ 3495 /* FIXME: Can h->dynindex be more than 64K? */
3496 if (h->dynindx & 0xffff0000) 3496 if (h->dynindx & 0xffff0000)
3497 return FALSE; 3497 return FALSE;
3498 3498
3499 /* Fill the stub. */ 3499 /* Fill the stub. */
3500 score_bfd_put_32 (output_bfd, STUB_LW, stub); 3500 score_bfd_put_32 (output_bfd, STUB_LW, stub);
3501 score_bfd_put_32 (output_bfd, STUB_MOVE, stub + 4); 3501 score_bfd_put_32 (output_bfd, STUB_MOVE, stub + 4);
3502 score_bfd_put_32 (output_bfd, STUB_LI16 | (h->dynindx << 1), stub + 8); 3502 score_bfd_put_32 (output_bfd, STUB_LI16 | (h->dynindx << 1), stub + 8);
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 struct bfd_link_info *info) 3561 struct bfd_link_info *info)
3562 { 3562 {
3563 bfd *dynobj; 3563 bfd *dynobj;
3564 asection *sdyn; 3564 asection *sdyn;
3565 asection *sgot; 3565 asection *sgot;
3566 asection *s; 3566 asection *s;
3567 struct score_got_info *g; 3567 struct score_got_info *g;
3568 3568
3569 dynobj = elf_hash_table (info)->dynobj; 3569 dynobj = elf_hash_table (info)->dynobj;
3570 3570
3571 sdyn = bfd_get_section_by_name (dynobj, ".dynamic"); 3571 sdyn = bfd_get_linker_section (dynobj, ".dynamic");
3572 3572
3573 sgot = score_elf_got_section (dynobj, FALSE); 3573 sgot = score_elf_got_section (dynobj, FALSE);
3574 if (sgot == NULL) 3574 if (sgot == NULL)
3575 g = NULL; 3575 g = NULL;
3576 else 3576 else
3577 { 3577 {
3578 BFD_ASSERT (score_elf_section_data (sgot) != NULL); 3578 BFD_ASSERT (score_elf_section_data (sgot) != NULL);
3579 g = score_elf_section_data (sgot)->u.got_info; 3579 g = score_elf_section_data (sgot)->u.got_info;
3580 BFD_ASSERT (g != NULL); 3580 BFD_ASSERT (g != NULL);
3581 } 3581 }
(...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after
4491 4491
4492 #define bfd_elf32_bfd_reloc_type_lookup elf32_score_reloc_type_lookup 4492 #define bfd_elf32_bfd_reloc_type_lookup elf32_score_reloc_type_lookup
4493 #define bfd_elf32_bfd_reloc_name_lookup \ 4493 #define bfd_elf32_bfd_reloc_name_lookup \
4494 elf32_score_reloc_name_lookup 4494 elf32_score_reloc_name_lookup
4495 #define bfd_elf32_bfd_link_hash_table_create elf32_score_link_hash_table_create 4495 #define bfd_elf32_bfd_link_hash_table_create elf32_score_link_hash_table_create
4496 #define bfd_elf32_bfd_print_private_bfd_data elf32_score_print_private_bfd_data 4496 #define bfd_elf32_bfd_print_private_bfd_data elf32_score_print_private_bfd_data
4497 #define bfd_elf32_bfd_merge_private_bfd_data elf32_score_merge_private_bfd_data 4497 #define bfd_elf32_bfd_merge_private_bfd_data elf32_score_merge_private_bfd_data
4498 #define bfd_elf32_new_section_hook elf32_score_new_section_hook 4498 #define bfd_elf32_new_section_hook elf32_score_new_section_hook
4499 4499
4500 #include "elf32-target.h" 4500 #include "elf32-target.h"
OLDNEW
« no previous file with comments | « bfd/elf32-s390.c ('k') | bfd/elf32-score7.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698