This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH for PR 20824] enable --warn-shared-textrel by default


Hi all,
  GNU-ld now disabled --warn-shared-textrel by default. IMO, it should be 
enabled by default, see 
https://sourceware.org/bugzilla/show_bug.cgi?id=20824.
  I'm told to send the patch here for discussions, sorry if this make 
troubles for you.

diff --exclude='*.rej' --exclude='*.orig' -Nuarp 
./binutils-2.27-org/ld/ldlex.h binutils-2.27/ld/ldlex.h
--- ./binutils-2.27-org/ld/ldlex.h               2016-11-15 
19:51:34.181123294 +0800
+++ binutils-2.27/ld/ldlex.h             2016-11-15 23:42:54.621117768 
+0800
@@ -129,6 +129,7 @@ enum option_values
   OPTION_WARN_UNRESOLVED_SYMBOLS,
   OPTION_ERROR_UNRESOLVED_SYMBOLS,
   OPTION_WARN_SHARED_TEXTREL,
+  OPTION_NO_WARN_SHARED_DT_TEXTREL,
   OPTION_WARN_ALTERNATE_EM,
   OPTION_REDUCE_MEMORY_OVERHEADS,
 #ifdef ENABLE_PLUGINS
diff --exclude='*.rej' --exclude='*.orig' -Nuarp 
./binutils-2.27-org/ld/lexsup.c binutils-2.27/ld/lexsup.c
--- ./binutils-2.27-org/ld/lexsup.c              2016-11-15 
19:51:35.102123294 +0800
+++ binutils-2.27/ld/lexsup.c            2016-11-15 23:43:08.192117761 
+0800
@@ -501,6 +501,9 @@ static const struct ld_option ld_options
   { {"warn-shared-textrel", no_argument, NULL, 
OPTION_WARN_SHARED_TEXTREL},
     '\0', NULL, N_("Warn if shared object has DT_TEXTREL"),
     TWO_DASHES },
+  { {"no-warn-shared-textrel", no_argument, NULL, 
OPTION_NO_WARN_SHARED_DT_TEXTREL},
+    '\0', NULL, N_("Do not warn DT_TEXTREL in a shared object"),
+    TWO_DASHES },
   { {"warn-alternate-em", no_argument, NULL, OPTION_WARN_ALTERNATE_EM},
     '\0', NULL, N_("Warn if an object has alternate ELF machine code"),
     TWO_DASHES },
@@ -546,6 +549,7 @@ parse_args (unsigned argc, char **argv)
   struct option *really_longopts;
   int last_optind;
   enum report_method how_to_report_unresolved_symbols = 
RM_GENERATE_ERROR;
+  int disable_dt_textrel=0;
 
   shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
   longopts = (struct option *)
@@ -1407,7 +1411,11 @@ parse_args (unsigned argc, char **argv)
                   break;
                 case OPTION_WARN_SHARED_TEXTREL:
                   link_info.warn_shared_textrel = TRUE;
+                  disable_dt_textrel = 0; 
                   break;
+                case OPTION_NO_WARN_SHARED_DT_TEXTREL:
+                  disable_dt_textrel = 1;
+                  break; 
                 case OPTION_WARN_ALTERNATE_EM:
                   link_info.warn_alternate_em = TRUE;
                   break;
@@ -1579,6 +1587,13 @@ parse_args (unsigned argc, char **argv)
     /* FIXME: Should we allow emulations a chance to set this ?  */
     link_info.unresolved_syms_in_shared_libs = 
how_to_report_unresolved_symbols;
 
+                if (link_info.shared == TRUE)
+  {
+                  if(disable_dt_textrel==1)
+                    link_info.warn_shared_textrel = FALSE;
+                  else 
+                    link_info.warn_shared_textrel = TRUE;
+                } 
   if (bfd_link_relocatable (&link_info)
       && command_line.check_section_addresses < 0)
     command_line.check_section_addresses = 0;



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]