Is your feature request related to a problem? Please describe.
When analyzing binaries generated on Fedora 29, compiled with -fcf-protection (Intel CET + MPX), it becomes much more confusing looking at calls to imported functions.

Describe the solution you’d like
Calls to .plt.sec entries should be identified as the ones to the usual .plt.

            0x00004e98      31c0           xor eax, eax
            0x00004e9a      e8a1e60000     call 0x13540
            0x00004e9f      488d351e4a01.  lea rsi, [0x000198c4]
            0x00004ea6      bf06000000     mov edi, 6
            0x00004eab      e8b0fdffff     call sym.imp.setlocale
            0x00004eb0      488d35584b01.  lea rsi, str.usr_share_locale ; 0x19a0f ; "/usr/share/locale"
            0x00004eb7      488d3d374b01.  lea rdi, [0x000199f5]       ; "coreutils"
            0x00004ebe      e81dfaffff     call sym.imp.bindtextdomain

Describe alternatives you’ve considered
None

Additional context

            0x00004e98      31c0           xor eax, eax
            0x00004e9a      e8a1e60000     call 0x13540
            0x00004e9f      488d351e4a01.  lea rsi, [0x000198c4]
            0x00004ea6      bf06000000     mov edi, 6
            0x00004eab      e8b0fdffff     call 0x4c60
            0x00004eb0      488d35584b01.  lea rsi, str.usr_share_locale ; 0x19a0f ; "/usr/share/locale"
            0x00004eb7      488d3d374b01.  lea rdi, [0x000199f5]       ; "coreutils"
            0x00004ebe      e81dfaffff     call 0x48e0

This is a snippet of the main function of /bin/ls on Fedora 29. The calls at 0x00004eab and 0x00004ebe are, respectively, calls to setlocale and bindtextdomain.

Binaries compiled with Intel CET/MPX support generates two .plt sections (.plt and .plt.sec).
.plt.sec entries are like:

            0x00004c60      f30f1efa       endbr64                                                                                                                                                                 
            0x00004c64      f2ff252de201.  bnd jmp qword reloc.setlocale    ; [0x22e98:8]=0x4560 ; "`E"                                                                                                            
            0x00004c6b      0f1f440000     nop dword [rax + rax]                    

.plt entries are like:

            0x00004040      f30f1efa       endbr64                                                                                                                                                                             
            0x00004044      6801000000     push 1                                                                                                                                                                              
            0x00004049      f2e9d1ffffff   bnd jmp 0x4020                          ;[1]                           

The binary calls the entry in .plt.sec. When the binary starts (unless it uses BIND_NOW) reloc.XXXXX points to the related entry in .plt, which calls the dynamic linker that resolve the symbol and put the resolved address in reloc.XXXXX. Next times the .plt.sec entry is called, it goes directly to the imported function.

Note that it’s enough to compile with MPX support to get .plt and .plt.sec

Reproducer

#include <stdio.h>

int main(int argc, char **argv) { printf("Good morning %s!\n", argv[0]); printf("Good night %s!\n", argv[0]); return 0; }

Compile with: gcc -O2 -ggdb -z bndplt test.c -o test-nocet-bndplt

 

 

 

其他:

  • MIPS: Drop .dynsym symbol ordering requirement and nullify DT_MIPS_XHASH
  • Hexagon: 希望实现TLSDESC
  • x86: Intel Control-flow Enhancement Technology (D59780)。对Intel坚持弄.plt.sec有点失望。 他们的说辞仅仅是早年弄MPX(已经被Linux移除,正在被Linux移除)也设计了这样的方案,并且在没有基准测试的情况下说这样或许对cache locality更友好。 对ppc了解更深后发现.plt.sec倒是和ppc32/ppc64 .glink有相似之处。ppc引入.glink是缺乏ADDPCIS时的无奈之举。x86这样设计则算明显缺陷,亦不利于未来增加新的PLT格式, 爲了避免未来再发生这种binutils行爲挟持LLVM/Clang/lld实现的例子,只能多关注binutils的变化了。另外值得一提,AArch64 8.3a 8.5a也有相似的特性Pointer AuthenticationBranch Target IdentificationLinker选项的语义AArch64x86有优雅。我试图在D59780挽救。

原文地址:http://www.cnblogs.com/ztguang/p/16852725.html

1. 本站所有资源来源于用户上传和网络,如有侵权请邮件联系站长! 2. 分享目的仅供大家学习和交流,请务用于商业用途! 3. 如果你也有好源码或者教程,可以到用户中心发布,分享有积分奖励和额外收入! 4. 本站提供的源码、模板、插件等等其他资源,都不包含技术服务请大家谅解! 5. 如有链接无法下载、失效或广告,请联系管理员处理! 6. 本站资源售价只是赞助,收取费用仅维持本站的日常运营所需! 7. 如遇到加密压缩包,默认解压密码为"gltf",如遇到无法解压的请联系管理员! 8. 因为资源和程序源码均为可复制品,所以不支持任何理由的退款兑现,请斟酌后支付下载 声明:如果标题没有注明"已测试"或者"测试可用"等字样的资源源码均未经过站长测试.特别注意没有标注的源码不保证任何可用性