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); + } } } }
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.
Patch applied.
Thanks!