@@ -5823,14 +5823,14 @@ static void plt_stub_flag(RCore *core, ut64 entry, ut64 size, ut64 slot) {
58235823 free (fname );
58245824}
58255825
5826- // walk the section decoding entries: remember the last lea and load, and when an
5827- // entry ends in an indirect jump derive the got slot it goes through
5826+ // decode entries, tracking the last lea/load to derive each got slot
58285827static void plt_stub_scan_section (RCore * core , RBinSection * sec ) {
58295828 if (sec -> vsize < 8 || sec -> vsize > 0x100000 ) {
58305829 return ;
58315830 }
58325831 const ut64 sec_vaddr = r_bin_get_vaddr (core -> bin , sec -> paddr , sec -> vaddr );
58335832 const int len = (int )sec -> vsize ;
5833+ const ut64 sec_end = sec_vaddr + len ;
58345834 ut8 * buf = malloc (len );
58355835 if (!buf || !r_io_read_at (core -> io , sec_vaddr , buf , len )) {
58365836 free (buf );
@@ -5857,15 +5857,13 @@ static void plt_stub_scan_section(RCore *core, RBinSection *sec) {
58575857 load_disp = UT64_MAX ;
58585858 continue ;
58595859 }
5860+ ut64 slot = UT64_MAX ;
58605861 if (indirect ) {
58615862 // x86 encodes the slot in one op; arm64-alikes split it lea/load/branch
5862- ut64 slot = (op .ptr > 0 && op .ptr != -1 )? (ut64 )op .ptr : UT64_MAX ;
5863+ slot = (op .ptr > 0 && op .ptr != -1 )? (ut64 )op .ptr : UT64_MAX ;
58635864 if (slot == UT64_MAX && lea_ptr != UT64_MAX && load_disp != UT64_MAX ) {
58645865 slot = lea_ptr + load_disp ;
58655866 }
5866- if (slot != UT64_MAX ) {
5867- plt_stub_flag (core , entry , at + oplen - entry , slot );
5868- }
58695867 } else {
58705868 switch (type ) {
58715869 case R_ANAL_OP_TYPE_LEA :
@@ -5887,6 +5885,11 @@ static void plt_stub_scan_section(RCore *core, RBinSection *sec) {
58875885 break ;
58885886 case R_ANAL_OP_TYPE_JMP :
58895887 case R_ANAL_OP_TYPE_CALL :
5888+ // retpoline stubs branch to an in-section thunk
5889+ if (lea_ptr != UT64_MAX && op .jump >= sec_vaddr && op .jump < sec_end ) {
5890+ slot = lea_ptr + ((load_disp == UT64_MAX )? 0 : load_disp );
5891+ }
5892+ break ;
58905893 case R_ANAL_OP_TYPE_UCALL :
58915894 case R_ANAL_OP_TYPE_RET :
58925895 case R_ANAL_OP_TYPE_TRAP :
@@ -5900,6 +5903,9 @@ static void plt_stub_scan_section(RCore *core, RBinSection *sec) {
59005903 break ;
59015904 }
59025905 }
5906+ if (slot != UT64_MAX ) {
5907+ plt_stub_flag (core , entry , at + oplen - entry , slot );
5908+ }
59035909 r_anal_op_fini (& op );
59045910 i += oplen ;
59055911 if (ends ) {
0 commit comments