[Bug gold/23769] New: gold: confusing error message for mixing split-stack and non-split-stack

2018-10-12 Thread cherryyz at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23769

Bug ID: 23769
   Summary: gold: confusing error message for mixing split-stack
and non-split-stack
   Product: binutils
   Version: 2.32 (HEAD)
Status: UNCONFIRMED
  Severity: minor
  Priority: P2
 Component: gold
  Assignee: ccoutant at gmail dot com
  Reporter: cherryyz at google dot com
CC: ian at airs dot com
  Target Milestone: ---

When using -r with mixed split-stack code and non-split-stack code, the gold
linker reports an error. When it sees a mismatch, it seems that it always
reports the first object as split-stack, and the second object as
non-split-stack. This message is confusing if the first object is
non-split-stack but the second is split-stack:

$ cc -fno-split-stack -c nosplit.c 
$ cc -fsplit-stack -c split.c 
$ ld.gold -r nosplit.o split.o
ld.gold: fatal error: cannot mix split-stack 'nosplit.o' and non-split-stack
'split.o' when using -r

In the error message, the name of the object files and whether they use split
stacks don't are swapped.

The following patch fixes the bug:

diff --git a/gold/gold.cc b/gold/gold.cc
index 1987d413d3..347c93cb90 100644
--- a/gold/gold.cc
+++ b/gold/gold.cc
@@ -631,10 +631,21 @@ queue_middle_tasks(const General_options& options,
  for (++p; p != input_objects->relobj_end(); ++p)
{
  if ((*p)->uses_split_stack() != uses_split_stack)
-   gold_fatal(_("cannot mix split-stack '%s' and "
-"non-split-stack '%s' when using -r"),
-  (*input_objects->relobj_begin())->name().c_str(),
-  (*p)->name().c_str());
+{
+  const char *name1 =
+(*input_objects->relobj_begin())->name().c_str();
+  const char *name2 = (*p)->name().c_str();
+  const char *name_split = name1;
+  const char *name_nosplit = name2;
+  if (!uses_split_stack)
+{
+  name_split = name2;
+  name_nosplit = name1;
+}
+  gold_fatal(_("cannot mix split-stack '%s' and "
+   "non-split-stack '%s' when using -r"),
+ name_split, name_nosplit);
+}
}
}
 }

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils


[Bug gold/23769] gold: confusing error message for mixing split-stack and non-split-stack

2018-10-17 Thread cherryyz at google dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=23769

--- Comment #3 from Cherry Zhang  ---
Thanks!

-- 
You are receiving this mail because:
You are on the CC list for the bug.
___
bug-binutils mailing list
bug-binutils@gnu.org
https://lists.gnu.org/mailman/listinfo/bug-binutils