Here is one particular case that causes gold PPC linker trapped in a endless relaxing loop. (I do not provide a reproducible case because the objects involved are proprietary). Here is the case - -------------- | | | 0x1b9446f0 | | | <- stub_table | ... | |------------| | | | | |------------| | 0x1c71e3d0 |----- |------------| | | | | | | | | | | jump delta = 0x2000000 | | | (>= max_branch_offset, which is 0x2000000) | | | | | | |------------| | | 0x1e71e3d0 | <--| |----------- | | | | | So a long branch stub is added, which is 16-byte, and this pushes the section forward, thus get to the following: -------------- | | | 0x1b9446f0 | | | <- stub_table | a new stub | | ... | |------------| | | | | |------------| | 0x1c71e3e0 |----- |------------| | | | | | | | | | | jump delta < 0x2000000 | | | no stub needed | | | | | | |------------| | | 0x1e71e3d0 | <--| (the jump target is *NOT* pushed forward? why?) |----------- | | | | | Now for this particular branch_info, we do not add a branch stub. So stub table shrinks by 16 bytes, and we get back to the first graph. Thus causes the indefinite loop. The solution is to only allow growth of stub tables after a few relax iterations.
The master branch has been updated by Han Shen <shenhan@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=6395d38b7ffd231a3b7b5a67b47e1bda947089ee commit 6395d38b7ffd231a3b7b5a67b47e1bda947089ee Author: Han Shen <shenhan@google.com> Date: Fri Aug 26 15:50:15 2016 -0700 PR gold/20529 - relaxing loop never ends. gold/ChangeLog 2016-08-26 Han Shen <shenhan@google.com> * powerpc.cc (Stub_table::min_size_threshold_): New member to limit size. (Stub_table::set_min_size_threshold): New member function. (Stub_table::set_address_and_size): Add code to only allow size increase. (Target_powerpc::do_relax): Add code to record last size.
The binutils-2_27-branch branch has been updated by Alan Modra <amodra@sourceware.org>: https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=cd54b50e7b5ac662ca52d636c01dfaa506cdb07b commit cd54b50e7b5ac662ca52d636c01dfaa506cdb07b Author: Han Shen <shenhan@google.com> Date: Fri Aug 26 15:50:15 2016 -0700 PR gold/20529 - relaxing loop never ends. * powerpc.cc (Stub_table::min_size_threshold_): New member to limit size. (Stub_table::set_min_size_threshold): New member function. (Stub_table::set_address_and_size): Add code to only allow size increase. (Target_powerpc::do_relax): Add code to record last size.
patch applied