https://sourceware.org/bugzilla/show_bug.cgi?id=29226
Jason Vas Dias <jason.vas.dias at gmail dot com> changed: What |Removed |Added ---------------------------------------------------------------------------- Priority|P2 |P1 CC| |jason.vas.dias at gmail dot com --- Comment #13 from Jason Vas Dias <jason.vas.dias at gmail dot com> --- OK, I discovered the SAME test fails completely without either of my patches, but BOTH allow the particular GCC build I was trying to succeed - I'm going with the last one : ---BEGIN PATCH diff -up gold/i386.cc~ gold/i386.cc --- gold/i386.cc~ 2022-06-05 02:23:38.826984954 +0100 +++ gold/i386.cc 2022-06-05 18:16:55.215927752 +0100 @@ -4190,12 +4190,34 @@ Target_i386::do_calls_non_split(Relobj* elfcpp::Swap_unaligned<32, false>::writeval(pval, val); } else - { - if (!object->has_no_split_stack()) + { bool is_rdssp = this->match_view(view, view_size, fnoffset, "\xf3\x0f\x1e", 3); + if ((!object->has_no_split_stack()) && + !is_rdssp + ) + { unsigned char ib[16]={0}; + if ( view ) + { ib[0] = *(((unsigned char*)view) + fnoffset); + ib[1] = *(((unsigned char*)view) + fnoffset + 1); + ib[2] = *(((unsigned char*)view) + fnoffset + 2); + ib[3] = *(((unsigned char*)view) + fnoffset + 3); + } object->error(_("failed to match split-stack sequence at " - "section %u offset %0zx"), - shndx, static_cast<size_t>(fnoffset)); - return; + "section %u offset %0zx #1:%c #2:%c %u %2.2hhx.%2.2hhx.%2.2hhx.%2.2hhx"), + shndx, static_cast<size_t>(fnoffset) + , (this->match_view(view, view_size, fnoffset, + "\x8d\x8c\x24", 3 + ) ? '1' : '0' + ) + , (this->match_view(view, view_size, fnoffset, + "\x8d\x8c\x94", 3 + ) ? '1' : '0' + ) + , static_cast<uint32_t>(fnsize) + , ib[0], ib[1], ib[2], ib[3] + ); + } + if ( ! is_rdssp ) + return; } // We have to change the function so that it calls diff -up gold/x86_64.cc~ gold/x86_64.cc --- gold/x86_64.cc~ 2022-01-22 12:14:09.000000000 +0000 +++ gold/x86_64.cc 2022-06-05 18:13:08.085938171 +0100 @@ -6044,10 +6044,12 @@ Target_x86_64<size>::do_ehframe_datarel_ static const unsigned char cmp_insn_32[] = { 0x64, 0x3b, 0x24, 0x25 }; static const unsigned char lea_r10_insn_32[] = { 0x44, 0x8d, 0x94, 0x24 }; static const unsigned char lea_r11_insn_32[] = { 0x44, 0x8d, 0x9c, 0x24 }; +static const unsigned char rdssp_insn_32[] = { 0xf3, 0x0f, 0x1e, 0xfa }; static const unsigned char cmp_insn_64[] = { 0x64, 0x48, 0x3b, 0x24, 0x25 }; static const unsigned char lea_r10_insn_64[] = { 0x4c, 0x8d, 0x94, 0x24 }; static const unsigned char lea_r11_insn_64[] = { 0x4c, 0x8d, 0x9c, 0x24 }; +static const unsigned char rdssp_insn_64[] = { 0xf3, 0x0f, 0x1e, 0xfa }; template<int size> void @@ -6067,7 +6069,9 @@ Target_x86_64<size>::do_calls_non_split( (size == 32 ? lea_r10_insn_32 : lea_r10_insn_64); const char* const lea_r11_insn = reinterpret_cast<const char*> (size == 32 ? lea_r11_insn_32 : lea_r11_insn_64); - + const char* const rdssp_insn = reinterpret_cast<const char*> + (size == 32 ? rdssp_insn_32 : rdssp_insn_64); + const size_t cmp_insn_len = (size == 32 ? sizeof(cmp_insn_32) : sizeof(cmp_insn_64)); const size_t lea_r10_insn_len = @@ -6075,6 +6079,7 @@ Target_x86_64<size>::do_calls_non_split( const size_t lea_r11_insn_len = (size == 32 ? sizeof(lea_r11_insn_32) : sizeof(lea_r11_insn_64)); const size_t nop_len = (size == 32 ? 7 : 8); + const size_t rdssp_insn_len = 4; // The function starts with a comparison of the stack pointer and a // field in the TCB. This is followed by a jump. @@ -6108,12 +6113,34 @@ Target_x86_64<size>::do_calls_non_split( elfcpp::Swap_unaligned<32, false>::writeval(pval, val); } else - { - if (!object->has_no_split_stack()) + { bool is_rdssp = this->match_view( view, view_size, fnoffset, rdssp_insn, rdssp_insn_len); + if ( (!object->has_no_split_stack()) + && !is_rdssp + ) + { unsigned char ib[16]={0}; + if ( view ) + { ib[0] = *(((unsigned char*)view) + fnoffset); + ib[1] = *(((unsigned char*)view) + fnoffset + 1); + ib[2] = *(((unsigned char*)view) + fnoffset + 2); + ib[3] = *(((unsigned char*)view) + fnoffset + 3); + } object->error(_("failed to match split-stack sequence at " - "section %u offset %0zx"), - shndx, static_cast<size_t>(fnoffset)); - return; + "section %u offset %0zx r10:%c r11:%c %u %2.2hhx.%2.2hhx.%2.2hhx.%2.2hhx"), + shndx, static_cast<size_t>(fnoffset) + , (this->match_view(view, view_size, fnoffset, + lea_r10_insn, lea_r10_insn_len + ) ? '1' : '0' + ) + , (this->match_view(view, view_size, fnoffset, + lea_r11_insn, lea_r11_insn_len + ) ? '1' : '0' + ) + , static_cast<uint32_t>(fnsize) + , ib[0], ib[1], ib[2], ib[3] + ); + } + if( !is_rdssp ) + return; } // We have to change the function so that it calls ---END PATCH -- You are receiving this mail because: You are on the CC list for the bug.