• R/O
  • HTTP
  • SSH
  • HTTPS

Commit

Tags
Aucun tag

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

GNU Binutils with patches for OS216


Commit MetaInfo

Révision66c103b772fdbc413d4727efa329babcab6617c5 (tree)
l'heure2008-09-07 13:02:31
AuteurAlan Modra <amodra@gmai...>
CommiterAlan Modra

Message de Log

* ldlang.h (lang_output_section_find): Define.
(lang_output_section_statement_lookup): Update prototype.
* ldlang.c (lang_output_section_find,
lang_output_section_statement_lookup_1): Merge into..
(lang_output_section_statement_lookup): ..here. Update all callers.
(process_insert_statements): Set constraint negative
for output section statements we might be inserting. Make error
fatal on not finding insertion section.
(lang_output_section_find): Rather than comparing
output_section_statement.constraint against -1, test whether
it is postive.
(lang_output_section_statement_lookup_1): Likewise.
(output_prev_sec_find, strip_excluded_output_sections): Likewise.
(lang_record_phdrs): Likewise.
* emultempl/elf32.em (output_rel_find): Likewise.
* NEWS: Mention INSERT.

Change Summary

Modification

--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,22 @@
1+2008-09-07 Alan Modra <amodra@bigpond.net.au>
2+
3+ * ldlang.h (lang_output_section_find): Define.
4+ (lang_output_section_statement_lookup): Update prototype.
5+ * ldlang.c (lang_output_section_find,
6+ lang_output_section_statement_lookup_1): Merge into..
7+ (lang_output_section_statement_lookup): ..here. Update all callers.
8+ (process_insert_statements): Set constraint negative
9+ for output section statements we might be inserting. Make error
10+ fatal on not finding insertion section.
11+ (lang_output_section_find): Rather than comparing
12+ output_section_statement.constraint against -1, test whether
13+ it is postive.
14+ (lang_output_section_statement_lookup_1): Likewise.
15+ (output_prev_sec_find, strip_excluded_output_sections): Likewise.
16+ (lang_record_phdrs): Likewise.
17+ * emultempl/elf32.em (output_rel_find): Likewise.
18+ * NEWS: Mention INSERT.
19+
120 2008-08-26 Nick Clifton <nickc@redhat.com>
221
322 PR 6727
--- a/ld/NEWS
+++ b/ld/NEWS
@@ -1,6 +1,9 @@
11 -*- text -*-
2+* Linker scripts support a new INSERT command that makes it easier to
3+ augment the default script.
4+
25 * Linker script input section filespecs may now specify a file within an
3- archive by writing "archive:file".
6+ archive by writing "archive:file".
47
58 * The --sort-common switch now has an optional argument which specifies the
69 direction of sorting.
@@ -8,9 +11,9 @@
811 * The M68K linker now supports multiple GOT generation schemes controlled via
912 the --got=<type> command line option.
1013
11-* The ARM EABI linker will now generate stubs for function calls to symbols that
12- are too far away. The placement of the stubs is controlled by a new linker
13- command line option: --stub-group-size=N.
14+* The ARM EABI linker will now generate stubs for function calls to symbols
15+ that are too far away. The placement of the stubs is controlled by a new
16+ linker command line option: --stub-group-size=N.
1417
1518 Changes in 2.18:
1619
--- a/ld/emultempl/elf32.em
+++ b/ld/emultempl/elf32.em
@@ -1583,7 +1583,7 @@ output_rel_find (asection *sec, int isdyn)
15831583 lookup != NULL;
15841584 lookup = lookup->next)
15851585 {
1586- if (lookup->constraint != -1
1586+ if (lookup->constraint >= 0
15871587 && CONST_STRNEQ (lookup->name, ".rel"))
15881588 {
15891589 int lookrela = lookup->name[4] == 'a';
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -1149,7 +1149,7 @@ lang_init (void)
11491149 first_file = lang_add_input_file (NULL, lang_input_file_is_marker_enum,
11501150 NULL);
11511151 abs_output_section =
1152- lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME);
1152+ lang_output_section_statement_lookup (BFD_ABS_SECTION_NAME, 0, TRUE);
11531153
11541154 abs_output_section->bfd_section = bfd_abs_section_ptr;
11551155
@@ -1255,44 +1255,19 @@ lang_memory_default (asection *section)
12551255 }
12561256
12571257 lang_output_section_statement_type *
1258-lang_output_section_find (const char *const name)
1258+lang_output_section_statement_lookup (const char *const name,
1259+ int constraint,
1260+ bfd_boolean create)
12591261 {
12601262 struct out_section_hash_entry *entry;
1261- unsigned long hash;
12621263
12631264 entry = ((struct out_section_hash_entry *)
12641265 bfd_hash_lookup (&output_section_statement_table, name,
1265- FALSE, FALSE));
1266+ create, FALSE));
12661267 if (entry == NULL)
1267- return NULL;
1268-
1269- hash = entry->root.hash;
1270- do
12711268 {
1272- if (entry->s.output_section_statement.constraint != -1)
1273- return &entry->s.output_section_statement;
1274- entry = (struct out_section_hash_entry *) entry->root.next;
1275- }
1276- while (entry != NULL
1277- && entry->root.hash == hash
1278- && strcmp (name, entry->s.output_section_statement.name) == 0);
1279-
1280- return NULL;
1281-}
1282-
1283-static lang_output_section_statement_type *
1284-lang_output_section_statement_lookup_1 (const char *const name, int constraint)
1285-{
1286- struct out_section_hash_entry *entry;
1287- struct out_section_hash_entry *last_ent;
1288- unsigned long hash;
1289-
1290- entry = ((struct out_section_hash_entry *)
1291- bfd_hash_lookup (&output_section_statement_table, name,
1292- TRUE, FALSE));
1293- if (entry == NULL)
1294- {
1295- einfo (_("%P%F: failed creating section `%s': %E\n"), name);
1269+ if (create)
1270+ einfo (_("%P%F: failed creating section `%s': %E\n"), name);
12961271 return NULL;
12971272 }
12981273
@@ -1300,10 +1275,12 @@ lang_output_section_statement_lookup_1 (const char *const name, int constraint)
13001275 {
13011276 /* We have a section of this name, but it might not have the correct
13021277 constraint. */
1303- hash = entry->root.hash;
1278+ struct out_section_hash_entry *last_ent;
1279+ unsigned long hash = entry->root.hash;
1280+
13041281 do
13051282 {
1306- if (entry->s.output_section_statement.constraint != -1
1283+ if (entry->s.output_section_statement.constraint >= 0
13071284 && (constraint == 0
13081285 || (constraint == entry->s.output_section_statement.constraint
13091286 && constraint != SPECIAL)))
@@ -1315,6 +1292,9 @@ lang_output_section_statement_lookup_1 (const char *const name, int constraint)
13151292 && entry->root.hash == hash
13161293 && strcmp (name, entry->s.output_section_statement.name) == 0);
13171294
1295+ if (!create)
1296+ return NULL;
1297+
13181298 entry
13191299 = ((struct out_section_hash_entry *)
13201300 output_section_statement_newfunc (NULL,
@@ -1334,12 +1314,6 @@ lang_output_section_statement_lookup_1 (const char *const name, int constraint)
13341314 return &entry->s.output_section_statement;
13351315 }
13361316
1337-lang_output_section_statement_type *
1338-lang_output_section_statement_lookup (const char *const name)
1339-{
1340- return lang_output_section_statement_lookup_1 (name, 0);
1341-}
1342-
13431317 /* A variant of lang_output_section_find used by place_orphan.
13441318 Returns the output statement that should precede a new output
13451319 statement for SEC. If an exact match is found on certain flags,
@@ -1502,7 +1476,7 @@ output_prev_sec_find (lang_output_section_statement_type *os)
15021476
15031477 for (lookup = os->prev; lookup != NULL; lookup = lookup->prev)
15041478 {
1505- if (lookup->constraint == -1)
1479+ if (lookup->constraint < 0)
15061480 continue;
15071481
15081482 if (lookup->bfd_section != NULL && lookup->bfd_section->owner != NULL)
@@ -3378,7 +3352,7 @@ map_input_to_output_sections
33783352 {
33793353 lang_output_section_statement_type *aos
33803354 = (lang_output_section_statement_lookup
3381- (s->address_statement.section_name));
3355+ (s->address_statement.section_name, 0, TRUE));
33823356
33833357 if (aos->bfd_section == NULL)
33843358 init_os (aos, NULL, 0);
@@ -3403,6 +3377,7 @@ process_insert_statements (void)
34033377 lang_statement_union_type **s;
34043378 lang_output_section_statement_type *first_os = NULL;
34053379 lang_output_section_statement_type *last_os = NULL;
3380+ lang_output_section_statement_type *os;
34063381
34073382 /* "start of list" is actually the statement immediately after
34083383 the special abs_section output statement, so that it isn't
@@ -3415,6 +3390,12 @@ process_insert_statements (void)
34153390 /* Keep pointers to the first and last output section
34163391 statement in the sequence we may be about to move. */
34173392 last_os = &(*s)->output_section_statement;
3393+
3394+ /* Set constraint negative so that lang_output_section_find
3395+ won't match this output section statement. At this
3396+ stage in linking constraint has values in the range
3397+ [-1, ONLY_IN_RW]. */
3398+ last_os->constraint = -2 - last_os->constraint;
34183399 if (first_os == NULL)
34193400 first_os = last_os;
34203401 }
@@ -3422,7 +3403,6 @@ process_insert_statements (void)
34223403 {
34233404 lang_insert_statement_type *i = &(*s)->insert_statement;
34243405 lang_output_section_statement_type *where;
3425- lang_output_section_statement_type *os;
34263406 lang_statement_union_type **ptr;
34273407 lang_statement_union_type *first;
34283408
@@ -3431,21 +3411,12 @@ process_insert_statements (void)
34313411 {
34323412 do
34333413 where = where->prev;
3434- while (where != NULL && where->constraint == -1);
3414+ while (where != NULL && where->constraint < 0);
34353415 }
34363416 if (where == NULL)
34373417 {
3438- einfo (_("%X%P: %s not found for insert\n"), i->where);
3439- continue;
3440- }
3441- /* You can't insert into the list you are moving. */
3442- for (os = first_os; os != NULL; os = os->next)
3443- if (os == where || os == last_os)
3444- break;
3445- if (os == where)
3446- {
3447- einfo (_("%X%P: %s not found for insert\n"), i->where);
3448- continue;
3418+ einfo (_("%F%P: %s not found for insert\n"), i->where);
3419+ return;
34493420 }
34503421
34513422 /* Deal with reordering the output section statement list. */
@@ -3482,6 +3453,7 @@ process_insert_statements (void)
34823453 last_sec = NULL;
34833454 for (os = first_os; os != NULL; os = os->next)
34843455 {
3456+ os->constraint = -2 - os->constraint;
34853457 if (os->bfd_section != NULL
34863458 && os->bfd_section->owner != NULL)
34873459 {
@@ -3542,6 +3514,14 @@ process_insert_statements (void)
35423514 s = &lang_output_section_statement.head;
35433515 }
35443516 }
3517+
3518+ /* Undo constraint twiddling. */
3519+ for (os = first_os; os != NULL; os = os->next)
3520+ {
3521+ os->constraint = -2 - os->constraint;
3522+ if (os == last_os)
3523+ break;
3524+ }
35453525 }
35463526
35473527 /* An output section might have been removed after its statement was
@@ -3569,7 +3549,7 @@ strip_excluded_output_sections (void)
35693549 asection *output_section;
35703550 bfd_boolean exclude;
35713551
3572- if (os->constraint == -1)
3552+ if (os->constraint < 0)
35733553 continue;
35743554
35753555 output_section = os->bfd_section;
@@ -5665,11 +5645,9 @@ lang_place_orphans (void)
56655645 || command_line.force_common_definition)
56665646 {
56675647 if (default_common_section == NULL)
5668- {
5669- default_common_section =
5670- lang_output_section_statement_lookup (".bss");
5671-
5672- }
5648+ default_common_section
5649+ = lang_output_section_statement_lookup (".bss", 0,
5650+ TRUE);
56735651 lang_add_section (&default_common_section->children, s,
56745652 default_common_section);
56755653 }
@@ -5680,7 +5658,7 @@ lang_place_orphans (void)
56805658 {
56815659 lang_output_section_statement_type *os;
56825660
5683- os = lang_output_section_statement_lookup (s->name);
5661+ os = lang_output_section_statement_lookup (s->name, 0, TRUE);
56845662 lang_add_section (&os->children, s, os);
56855663 }
56865664 }
@@ -5827,12 +5805,10 @@ lang_enter_output_section_statement (const char *output_section_statement_name,
58275805 {
58285806 lang_output_section_statement_type *os;
58295807
5830- os = lang_output_section_statement_lookup_1 (output_section_statement_name,
5831- constraint);
5808+ os = lang_output_section_statement_lookup (output_section_statement_name,
5809+ constraint, TRUE);
58325810 current_section = os;
58335811
5834- /* Make next things chain into subchain of this. */
5835-
58365812 if (os->addr_tree == NULL)
58375813 {
58385814 os->addr_tree = address_exp;
@@ -5843,6 +5819,8 @@ lang_enter_output_section_statement (const char *output_section_statement_name,
58435819 else
58445820 os->flags = SEC_NEVER_LOAD;
58455821 os->block_value = 1;
5822+
5823+ /* Make next things chain into subchain of this. */
58465824 stat_ptr = &os->children;
58475825
58485826 os->subsection_alignment =
@@ -6639,7 +6617,7 @@ lang_record_phdrs (void)
66396617 {
66406618 lang_output_section_phdr_list *pl;
66416619
6642- if (os->constraint == -1)
6620+ if (os->constraint < 0)
66436621 continue;
66446622
66456623 pl = os->phdrs;
@@ -6720,7 +6698,7 @@ lang_record_phdrs (void)
67206698 {
67216699 lang_output_section_phdr_list *pl;
67226700
6723- if (os->constraint == -1
6701+ if (os->constraint < 0
67246702 || os->bfd_section == NULL)
67256703 continue;
67266704
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -525,12 +525,13 @@ extern void lang_do_assignments
525525 statement != (lang_input_statement_type *) NULL; \
526526 statement = (lang_input_statement_type *) statement->next) \
527527
528+#define lang_output_section_find(NAME) \
529+ lang_output_section_statement_lookup (NAME, 0, FALSE)
530+
528531 extern void lang_process
529532 (void);
530533 extern void ldlang_add_file
531534 (lang_input_statement_type *);
532-extern lang_output_section_statement_type *lang_output_section_find
533- (const char * const);
534535 extern lang_output_section_statement_type *lang_output_section_find_by_flags
535536 (const asection *, lang_output_section_statement_type **,
536537 lang_match_sec_type_func);
@@ -541,9 +542,8 @@ extern lang_input_statement_type *lang_add_input_file
541542 (const char *, lang_input_file_enum_type, const char *);
542543 extern void lang_add_keepsyms_file
543544 (const char *);
544-extern lang_output_section_statement_type *
545- lang_output_section_statement_lookup
546- (const char *const);
545+extern lang_output_section_statement_type *lang_output_section_statement_lookup
546+ (const char *const, int, bfd_boolean);
547547 extern void ldlang_add_undef
548548 (const char *const);
549549 extern void lang_add_output_format