Bug 23769 - gold: confusing error message for mixing split-stack and non-split-stack
Summary: gold: confusing error message for mixing split-stack and non-split-stack
Status: RESOLVED FIXED
Alias: None
Product: binutils
Classification: Unclassified
Component: gold (show other bugs)
Version: 2.32
: P2 minor
Target Milestone: 2.32
Assignee: Alan Modra
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-10-13 00:28 UTC by Cherry Zhang
Modified: 2018-10-18 03:54 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Cherry Zhang 2018-10-13 00:28:06 UTC
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);
+                }
            }
        }
     }
Comment 1 Sourceware Commits 2018-10-16 06:19:34 UTC
The master branch has been updated by Alan Modra <amodra@sourceware.org>:

https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=08ea4a7805705668c2c4c63b858b6641d052f7e7

commit 08ea4a7805705668c2c4c63b858b6641d052f7e7
Author: Cherry Zhang <cherryyz@google.com>
Date:   Tue Oct 16 14:07:41 2018 +1030

    PR23769, mixing split-stack and non-split-stack error message
    
    Corrects which file is reported as being split-stack.
    
    	PR 23769
    	* gold.cc (queue_middle_tasks): Correct split-stack error message.
Comment 2 Alan Modra 2018-10-16 06:25:41 UTC
Patch applied.
Comment 3 Cherry Zhang 2018-10-18 03:54:27 UTC
Thanks!