From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26305 invoked by alias); 1 Oct 2004 14:42:16 -0000 Mailing-List: contact binutils-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: binutils-owner@sources.redhat.com Received: (qmail 26274 invoked from network); 1 Oct 2004 14:42:15 -0000 Received: from unknown (HELO nimbus.ott.qnx.com) (209.226.137.76) by sourceware.org with SMTP; 1 Oct 2004 14:42:15 -0000 Received: from [10.12.1.178] (dhcpa178.ott.qnx.com [10.12.1.178]) by nimbus.ott.qnx.com with SMTP (Microsoft Exchange Internet Mail Service Version 5.5.2653.13) id S8QHFRM9; Fri, 1 Oct 2004 10:42:15 -0400 Message-ID: <415D6CC6.8040103@qnx.com> Date: Fri, 01 Oct 2004 14:42:00 -0000 From: Jeff Baker Reply-To: jbaker@qnx.com Organization: QNX Software Systems Ltd. User-Agent: Mozilla Thunderbird 0.8 (Windows/20040913) MIME-Version: 1.0 To: Nick Clifton CC: binutils@sources.redhat.com Subject: Re: [PATCH] Add --warn-shared-textrel option to ld References: <415C43A4.5070501@redhat.com> In-Reply-To: <415C43A4.5070501@redhat.com> Content-Type: multipart/mixed; boundary="------------020806090006010106070604" X-SW-Source: 2004-10/txt/msg00016.txt.bz2 This is a multi-part message in MIME format. --------------020806090006010106070604 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-length: 464 > Well the patch seems quite reasonable. There are a couple of minor > problems with it however: > > * The formatting of the code added to elflink.c does not follow the > GNU Coding Standards; (the opening curly brace should be on its own > line). > > * The patch adds a new command line switch to the linker, but it does > > not add documentation on this switch to the ld.texinfo file, nor does it > > add a line to the ld/NEWS file. How about now? --------------020806090006010106070604 Content-Type: text/plain; name="qnx_shared_textrel.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="qnx_shared_textrel.patch" Content-length: 7334 2004-10-01 Jeff Baker * elflink.c (_bfd_elf_add_dynamic_entry): Add code to warn if adding a DT_TEXTREL to a shared object and --warn-shared-textrel was specified. 2004-10-01 Jeff Baker * bfdlink.h (bfd_link_info): Add boolean warn_shared_textrel. 2004-10-01 Jeff Baker * NEWS: Added mention of --warn-shared-textrel option. * ld.texinfo: Add documentation for --warn-shared-textrel. * lexsup.c: Handle --warn-shared-textrel option. Index: bfd/elflink.c =================================================================== RCS file: /cvs/src/src/bfd/elflink.c,v retrieving revision 1.104 diff -w -u -1 -0 -p -r1.104 elflink.c --- bfd/elflink.c 30 Sep 2004 16:43:41 -0000 1.104 +++ bfd/elflink.c 1 Oct 2004 14:35:35 -0000 @@ -2694,20 +2694,26 @@ _bfd_elf_add_dynamic_entry (struct bfd_l const struct elf_backend_data *bed; asection *s; bfd_size_type newsize; bfd_byte *newcontents; Elf_Internal_Dyn dyn; hash_table = elf_hash_table (info); if (! is_elf_hash_table (hash_table)) return FALSE; + if (info->warn_shared_textrel && info->shared && tag == DT_TEXTREL) + { + (*_bfd_error_handler) + (_("warning: creating a DT_TEXTREL in a shared object.")); + } + bed = get_elf_backend_data (hash_table->dynobj); s = bfd_get_section_by_name (hash_table->dynobj, ".dynamic"); BFD_ASSERT (s != NULL); newsize = s->size + bed->s->sizeof_dyn; newcontents = bfd_realloc (s->contents, newsize); if (newcontents == NULL) return FALSE; dyn.d_tag = tag; Index: include/bfdlink.h =================================================================== RCS file: /cvs/src/src/include/bfdlink.h,v retrieving revision 1.46 diff -w -u -1 -0 -p -r1.46 bfdlink.h --- include/bfdlink.h 17 Sep 2004 07:14:32 -0000 1.46 +++ include/bfdlink.h 1 Oct 2004 14:35:35 -0000 @@ -393,20 +393,23 @@ struct bfd_link_info unsigned int spare_dynamic_tags; /* May be used to set DT_FLAGS for ELF. */ bfd_vma flags; /* May be used to set DT_FLAGS_1 for ELF. */ bfd_vma flags_1; /* Start and end of RELRO region. */ bfd_vma relro_start, relro_end; + + /* Warn if adding a DT_TEXTREL to a shared object. */ + bfd_boolean warn_shared_textrel; }; /* This structures holds a set of callback functions. These are called by the BFD linker routines. The first argument to each callback function is the bfd_link_info structure being used. Each function returns a boolean value. If the function returns FALSE, then the BFD function which called it will return with a failure indication. */ struct bfd_link_callbacks Index: ld/lexsup.c =================================================================== RCS file: /cvs/src/src/ld/lexsup.c,v retrieving revision 1.76 diff -w -u -1 -0 -p -r1.76 lexsup.c --- ld/lexsup.c 19 Jul 2004 16:40:52 -0000 1.76 +++ ld/lexsup.c 1 Oct 2004 14:35:35 -0000 @@ -139,21 +139,22 @@ enum option_values OPTION_NOSTDLIB, OPTION_NO_OMAGIC, OPTION_STRIP_DISCARDED, OPTION_NO_STRIP_DISCARDED, OPTION_ACCEPT_UNKNOWN_INPUT_ARCH, OPTION_NO_ACCEPT_UNKNOWN_INPUT_ARCH, OPTION_PIE, OPTION_UNRESOLVED_SYMBOLS, OPTION_WARN_UNRESOLVED_SYMBOLS, OPTION_ERROR_UNRESOLVED_SYMBOLS, - OPTION_REDUCE_MEMORY_OVERHEADS + OPTION_REDUCE_MEMORY_OVERHEADS, + OPTION_WARN_SHARED_TEXTREL }; /* The long options. This structure is used for both the option parsing and the help text. */ struct ld_option { /* The long option information. */ struct option opt; /* The short option with the same meaning ('\0' if none). */ @@ -489,20 +490,23 @@ static const struct ld_option ld_options "\t\t\t\tfollowing dynamic libs"), TWO_DASHES }, { {"no-add-needed", no_argument, NULL, OPTION_NO_ADD_NEEDED}, '\0', NULL, N_("Do not set DT_NEEDED tags for DT_NEEDED entries\n" "\t\t\t\tin following dynamic libs"), TWO_DASHES }, { {"as-needed", no_argument, NULL, OPTION_AS_NEEDED}, '\0', NULL, N_("Only set DT_NEEDED for following dynamic libs if used"), TWO_DASHES }, { {"no-as-needed", no_argument, NULL, OPTION_NO_AS_NEEDED}, '\0', NULL, N_("Always set DT_NEEDED for following dynamic libs"), TWO_DASHES }, + { {"warn-shared-textrel", no_argument, NULL, OPTION_WARN_SHARED_TEXTREL}, + '\0', NULL, N_("Warn if shared object has DT_TEXTREL"), + TWO_DASHES }, { {"wrap", required_argument, NULL, OPTION_WRAP}, '\0', N_("SYMBOL"), N_("Use wrapper functions for SYMBOL"), TWO_DASHES }, }; #define OPTION_COUNT ARRAY_SIZE (ld_options) void parse_args (unsigned argc, char **argv) { unsigned i; @@ -1209,20 +1213,23 @@ parse_args (unsigned argc, char **argv) break; case OPTION_NO_ADD_NEEDED: add_needed = FALSE; break; case OPTION_AS_NEEDED: as_needed = TRUE; break; case OPTION_NO_AS_NEEDED: as_needed = FALSE; break; + case OPTION_WARN_SHARED_TEXTREL: + link_info.warn_shared_textrel = TRUE; + break; case OPTION_WRAP: add_wrap (optarg); break; case OPTION_DISCARD_NONE: link_info.discard = discard_none; break; case 'X': link_info.discard = discard_l; break; case 'x': Index: ld/ld.texinfo =================================================================== RCS file: /cvs/src/src/ld/ld.texinfo,v retrieving revision 1.122 diff -w -u -1 -0 -p -r1.122 ld.texinfo --- ld/ld.texinfo 30 Sep 2004 17:03:51 -0000 1.122 +++ ld/ld.texinfo 1 Oct 2004 14:35:37 -0000 @@ -1673,20 +1673,24 @@ which refers to it. @kindex --warn-section-align @cindex warnings, on section alignment @cindex section alignment, warnings on @item --warn-section-align Warn if the address of an output section is changed because of alignment. Typically, the alignment will be set by an input section. The address will only be changed if it not explicitly specified; that is, if the @code{SECTIONS} command does not specify a start address for the section (@pxref{SECTIONS}). +@kindex --warn-shared-textrel +@item --warn-shared-textrel +Warn if the linker adds a DT_TEXTREL to a shared object. + @kindex --warn-unresolved-symbols @item --warn-unresolved-symbols If the linker is going to report an unresolved symbol (see the option @option{--unresolved-symbols}) it will normally generate an error. This option makes it generate a warning instead. @kindex --error-unresolved-symbols @item --error-unresolved-symbols This restores the linker's default behaviour of generating errors when it is reporting unresolved symbols. Index: ld/NEWS =================================================================== RCS file: /cvs/src/src/ld/NEWS,v retrieving revision 1.50 diff -w -u -1 -0 -p -r1.50 NEWS --- ld/NEWS 19 Jul 2004 19:14:51 -0000 1.50 +++ ld/NEWS 1 Oct 2004 14:35:37 -0000 @@ -1,12 +1,15 @@ -*- text -*- +* New ELF --warn-shared-textrel option to warn if adding a +DT_TEXTREL to a shared object. + * New ELF --add-needed/--no-add-needed options to control if a DT_NEEDED tag should be added when a shared library comes from DT_NEEDED tags. * Support for the crx-elf target added. * Support for the sh-symbianelf target added. * A new linker command line switch has been added which allows the hash table size to be set to a suitable prime value near to its argument. This switch --------------020806090006010106070604--