From 3535c3c04433d0b88e55338b240c25101a9bb8e0 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Thu, 26 Mar 1998 00:00:54 +0000 Subject: [PATCH] Add interworking support for arm-pe/thumb-pe targets. --- ld/ChangeLog | 9 +++ ld/emultempl/pe.em | 172 +++++++++++++++++++++++++++++++-------------- 2 files changed, 129 insertions(+), 52 deletions(-) diff --git a/ld/ChangeLog b/ld/ChangeLog index 03e211919af..b8db877539c 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -8,6 +8,15 @@ Wed Mar 25 11:34:13 1998 Ian Lance Taylor * scripttempl/pe.sc: Only include .idata\$[0-7] in .idata when relocating. +Tue Mar 24 15:59:29 1998 Nick Clifton + + * scripttempl/pe.sc (.text): Add .glue_7 and .glue_7t sections to + hold Arm/Thumb stubs. + + * emultempl/pe.em (gld_pe_before_allocation): Call + arm_process_before_allocation (for ARM/Thumb targets) in order to + gather interworking stb information. + Mon Mar 23 18:54:15 1998 Joel Sherrill * configure.tgt: (sh*-*-rtems*): Switched from ELF to COFF. diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em index 838a010ee32..bee6798e6dc 100644 --- a/ld/emultempl/pe.em +++ b/ld/emultempl/pe.em @@ -1,15 +1,8 @@ # This shell script emits a C file. -*- C -*- # It does some substitutions. cat >e${EMULATION_NAME}.c <pe) { einfo ("%F%P: PE operations on non PE file.\n"); @@ -406,6 +444,13 @@ sort_by_file_name (a, b) { lang_statement_union_type **ra = a; lang_statement_union_type **rb = b; + int i; + + i = strcmp ((*ra)->input_section.ifile->the_bfd->my_archive->filename, + (*rb)->input_section.ifile->the_bfd->my_archive->filename); + if (i != 0) + return i; + return strcmp ((*ra)->input_section.ifile->filename, (*rb)->input_section.ifile->filename); } @@ -434,12 +479,13 @@ sort_sections_1 (startptr, next_after, count, sort_func) lang_statement_union_type **vec; lang_statement_union_type *p; int i; + lang_statement_union_type **ret; if (count == 0) return startptr; - vec = (lang_statement_union_type **) - alloca (count * sizeof (lang_statement_union_type *)); + vec = ((lang_statement_union_type **) + xmalloc (count * sizeof (lang_statement_union_type *))); for (p = *startptr, i = 0; i < count; i++, p = p->next) vec[i] = p; @@ -451,7 +497,9 @@ sort_sections_1 (startptr, next_after, count, sort_func) for (i = 0; i < count - 1; i++) vec[i]->header.next = vec[i + 1]; vec[i]->header.next = next_after; - return &(vec[i]->header.next); + ret = &vec[i]->header.next; + free (vec); + return ret; } /* Sort the .idata\$foo input sections of archives into filename order. @@ -486,12 +534,12 @@ sort_sections (s) if (s->wild_statement.section_name != NULL && strncmp (s->wild_statement.section_name, ".idata", 6) == 0) { - /* Sort any children in the same archive. Run through all - the children of this wild statement, when an - input_section in an archive is found, scan forward to - find all input_sections which are in the same archive. - Sort them by their filename and then re-thread the - pointer chain. */ + /* Sort the children. We want to sort any objects in + the same archive. In order to handle the case of + including a single archive multiple times, we sort + all the children by archive name and then by object + name. After sorting them, we re-thread the pointer + chain. */ while (*p) { @@ -505,9 +553,7 @@ sort_sections (s) int count; for (end = start, count = 0; - end && end->header.type == lang_input_section_enum - && (end->input_section.ifile->the_bfd->my_archive - == start->input_section.ifile->the_bfd->my_archive); + end && end->header.type == lang_input_section_enum; end = end->next) count++; @@ -518,15 +564,18 @@ sort_sections (s) } /* If this is a collection of grouped sections, sort them. - The linker script must explicitly mention "*(.foo\$)". - Don't sort them if \$ is not the last character (not sure if - this is really useful, but it allows explicitly mentioning - some \$ sections and letting the linker handle the rest). */ + The linker script must explicitly mention "*(.foo\$)" or + "*(.foo\$*)". Don't sort them if \$ is not the last + character (not sure if this is really useful, but it + allows explicitly mentioning some \$ sections and letting + the linker handle the rest). */ if (s->wild_statement.section_name != NULL) { char *q = strchr (s->wild_statement.section_name, '\$'); - if (q && q[1] == 0) + if (q != NULL + && (q[1] == '\0' + || (q[1] == '*' && q[2] == '\0'))) { lang_statement_union_type *end; int count; @@ -560,13 +609,29 @@ gld_${EMULATION_NAME}_before_allocation() { if (!ppc_process_before_allocation(is->the_bfd, &link_info)) { - einfo("Errors encountered processing file %s", is->filename); + einfo("Errors encountered processing file %s\n", is->filename); } } } /* We have seen it all. Allocate it, and carry on */ ppc_allocate_toc_section (&link_info); +#else + /* FIXME: we should be able to set the size of the interworking stub section */ + /* Here we rummage through the found bfds to collect glue information. */ + /* FIXME: should this be based on a command line option? krk@cygnus.com */ + { + LANG_FOR_EACH_INPUT_STATEMENT (is) + { + if (!arm_process_before_allocation (is->the_bfd, & link_info)) + { + einfo ("Errors encountered processing file %s", is->filename); + } + } + } + + /* We have seen it all. Allocate it, and carry on */ + arm_allocate_interworking_sections (& link_info); #endif sort_sections (stat_ptr->head); @@ -577,7 +642,11 @@ gld_${EMULATION_NAME}_before_allocation() gets mapped to the output section with everything from the '\$' on stripped (e.g. .text). See the Microsoft Portable Executable and Common Object File Format - Specification 4.1, section 4.2, Grouped Sections. */ + Specification 4.1, section 4.2, Grouped Sections. + + FIXME: This is now handled by the linker script using wildcards, + but I'm leaving this here in case we want to enable it for sections + which are not mentioned in the linker script. */ /*ARGSUSED*/ static boolean @@ -588,7 +657,6 @@ gld${EMULATION_NAME}_place_orphan (file, s) const char *secname; char *output_secname, *ps; lang_output_section_statement_type *os; - lang_statement_list_type *ptr; lang_statement_union_type *l; if ((s->flags & SEC_ALLOC) == 0) -- 2.30.2