public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
From: Jeff Baker <jbaker@qnx.com>
To: jbaker@qnx.com
Cc: binutils@sources.redhat.com
Subject: Re: [PATCH] Add --warn-shared-textrel option to ld
Date: Tue, 21 Sep 2004 18:16:00 -0000	[thread overview]
Message-ID: <41506ED7.6050807@qnx.com> (raw)
In-Reply-To: <4149DBF2.9080207@qnx.com>

Ping.

Jeff Baker wrote:
> This patch was originally included in the QNX Mips support but I'm 
> posting it on it's own so that the appropriate people might look at it.
> 
> 
> 
> ------------------------------------------------------------------------
> 
> 2004-09-13  Jeff Baker  <jbaker@qnx.com>
> 	* 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-09-13  Jeff Baker  <jbaker@qnx.com>
> 	* bfdlink.h (bfd_link_info): Add boolean
> 	warn_shared_textrel.
> 
> 2004-09-13  Jeff Baker  <jbaker@qnx.com>
> 	* lexsup.c: Handle --warn-shared-textrel option.
> 
> Index: bfd/elflink.c
> ===================================================================
> RCS file: /cvs/src/src/bfd/elflink.c,v
> retrieving revision 1.101
> diff -w -u -1 -0 -p -r1.101 elflink.c
> --- bfd/elflink.c	7 Sep 2004 13:40:37 -0000	1.101
> +++ bfd/elflink.c	13 Sep 2004 18:24:51 -0000
> @@ -2644,20 +2644,25 @@ _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.45
> diff -w -u -1 -0 -p -r1.45 bfdlink.h
> --- include/bfdlink.h	13 Aug 2004 03:16:01 -0000	1.45
> +++ include/bfdlink.h	13 Sep 2004 18:25:04 -0000
> @@ -390,20 +390,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	13 Sep 2004 18:25:13 -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':

  reply	other threads:[~2004-09-21 18:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-09-16 18:31 Jeff Baker
2004-09-21 18:16 ` Jeff Baker [this message]
2004-09-30 17:30 ` Nick Clifton
2004-10-01 14:42   ` Jeff Baker
2004-10-07 14:46     ` Nick Clifton
2005-03-24  3:50       ` Ned Ludd

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=41506ED7.6050807@qnx.com \
    --to=jbaker@qnx.com \
    --cc=binutils@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).