summaryrefslogtreecommitdiff
path: root/ld/lexsup.c
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2014-01-10 06:17:23 -0800
committerH.J. Lu <hjl.tools@gmail.com>2014-01-10 06:17:23 -0800
commit82b177ee22f39cbe105834b8a6f25a87496dada8 (patch)
treed2c15b8f5d09ac45b1401f3b7bedec6b9446b4c6 /ld/lexsup.c
parenteec2f3ed9f053653ed5d629eb50e08e3ee61e9bd (diff)
downloadbinutils-gdb-82b177ee22f39cbe105834b8a6f25a87496dada8.tar.gz
Disallow -shared/-pie, -shared/-static, -pie/-staticusers/hjl/pr16428
ld/ PR ld/16428 * ld.texinfo: Updated for -static/-non_shared change. * ldlex.h (option_values): Add OPTION_STATIC. * lexsup.c (ld_options): Use OPTION_STATIC for -static/-non_shared. (parse_args): Handle OPTION_STATIC. Disallow -shared and -pie, -shared and -static, -pie and -static. ld/testsuite/ 2014-01-10 H.J. Lu <hongjiu.lu@intel.com> PR ld/16428 * ld-elf/pr16428a.d: New file. * ld-elf/pr16428b.d: Likewise. * ld-elf/pr16428c.d: Likewise. * ld-elf/pr16428d.d: Likewise.
Diffstat (limited to 'ld/lexsup.c')
-rw-r--r--ld/lexsup.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 2f717502465..a366613dae0 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -269,9 +269,9 @@ static const struct ld_option ld_options[] =
'\0', NULL, N_("Do not link against shared libraries"), ONE_DASH },
{ {"dn", no_argument, NULL, OPTION_NON_SHARED},
'\0', NULL, NULL, ONE_DASH },
- { {"non_shared", no_argument, NULL, OPTION_NON_SHARED},
+ { {"non_shared", no_argument, NULL, OPTION_STATIC},
'\0', NULL, NULL, ONE_DASH },
- { {"static", no_argument, NULL, OPTION_NON_SHARED},
+ { {"static", no_argument, NULL, OPTION_STATIC},
'\0', NULL, NULL, ONE_DASH },
{ {"Bsymbolic", no_argument, NULL, OPTION_SYMBOLIC},
'\0', NULL, N_("Bind global references locally"), ONE_DASH },
@@ -523,6 +523,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;
+ bfd_boolean seen_pie = FALSE, seen_shared = FALSE, seen_static = FALSE;
shortopts = (char *) xmalloc (OPTION_COUNT * 3 + 2);
longopts = (struct option *)
@@ -707,6 +708,8 @@ parse_args (unsigned argc, char **argv)
case OPTION_CALL_SHARED:
input_flags.dynamic = TRUE;
break;
+ case OPTION_STATIC:
+ seen_static = TRUE;
case OPTION_NON_SHARED:
input_flags.dynamic = FALSE;
break;
@@ -1087,6 +1090,7 @@ parse_args (unsigned argc, char **argv)
case OPTION_SHARED:
if (config.has_shared)
{
+ seen_shared = TRUE;
link_info.shared = TRUE;
/* When creating a shared library, the default
behaviour is to ignore any unresolved references. */
@@ -1101,6 +1105,7 @@ parse_args (unsigned argc, char **argv)
case OPTION_PIE:
if (config.has_shared)
{
+ seen_pie = TRUE;
link_info.shared = TRUE;
link_info.pie = TRUE;
}
@@ -1445,6 +1450,16 @@ parse_args (unsigned argc, char **argv)
}
}
+ if (seen_shared)
+ {
+ if (seen_pie)
+ einfo (_("%P%F: -shared and -pie are incompatible\n"));
+ if (seen_static)
+ einfo (_("%P%F: -shared and -static are incompatible\n"));
+ }
+ if (seen_pie && seen_static)
+ einfo (_("%P%F: -pie and -static are incompatible\n"));
+
while (ingroup)
{
lang_leave_group ();