逆向-beginners之C++ 全局使用string字符串

#include <stdio.h>
#include <string>

std::string s = "a string";

int main()
{
    printf("%s\n", s.c_str());
}

#if 0

实际上由STL定义的数据类型都可以用作全局变量。


#endif

#if 0
/*
 * intel
 */
0000000000001229 <main>:
    1229:    f3 0f 1e fa              endbr64
    122d:    55                       push   %rbp
    122e:    48 89 e5                 mov    %rsp,%rbp
    1231:    48 8d 3d 08 2e 00 00     lea    0x2e08(%rip),%rdi        # 4040 <_Z1sB5cxx11>
    1238:    e8 83 fe ff ff           callq  10c0 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv@plt>
    123d:    48 89 c7                 mov    %rax,%rdi
    1240:    e8 cb fe ff ff           callq  1110 <puts@plt>
    1245:    b8 00 00 00 00           mov    $0x0,%eax
    124a:    5d                       pop    %rbp
    124b:    c3                       retq   

/*
 * arm
 */
00000000004009ec <main>:
  4009ec:    a9bf7bfd     stp    x29, x30, [sp, #-16]!
  4009f0:    910003fd     mov    x29, sp
  4009f4:    b0000080     adrp    x0, 411000 <__libc_start_main@GLIBC_2.17>
  4009f8:    91020000     add    x0, x0, #0x80
  4009fc:    97ffffa5     bl    400890 <_ZNKSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE5c_strEv@plt>
  400a00:    97ffffa8     bl    4008a0 <puts@plt>
  400a04:    52800000     mov    w0, #0x0                       // #0
  400a08:    a8c17bfd     ldp    x29, x30, [sp], #16
  400a0c:    d65f03c0     ret


#endif

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值