我正在查看一个反汇编的 C++ 块,它可以与多个std::string实例一起使用。我曾被多次调用 的各种版本所迷惑std::operator+,但这个调用似乎完全错误(无论如何我的理解):
mov rax, qword [rbp-0xb8]
lea rbx, qword [rax+0xa0]
lea rax, qword [rbp-0x60]
mov edx, 0x880d32 ; "/store/"
mov rsi, rax
mov rdi, rbx
; std::string std::operator+(std::string &&, char const *),
call _ZStplIcSt11char_traitsIcESaIcEENSt7__cxx1112basic_stringIT_T0_T1_EEOS8_PKS5_
lea rax, qword [rbp-0x60]
从上下文中,我确定引用的堆栈值是:
rbp-0x60:std::string堆栈上的一个,用std::string(char const *, std::allocator<char> &).rbp-0xb8: 指向this.
从该.comment部分,我可以看到使用的编译器是 GCC 5.4.0,我从中检索了operator+上面调用的这个实现(在namespace std { ... }):
template<typename _CharT, typename _Traits, typename _Alloc>
inline
basic_string<_CharT, _Traits, _Alloc>
operator+(
basic_string<_CharT, _Traits, _Alloc> &&__lhs,
const _CharT *__rhs)
{
return std::move(__lhs.append(__rhs));
}
我可以理解由于__lhs被 修改而被优化掉的返回值operator+,但参数似乎不匹配。edx引用 onlychar *建议在源代码中声明的参数之前添加一个额外的第一个参数。如果这是一个成员函数,我希望(rdi是this),但operator+作为非成员实现。
我在这里的调用约定中遗漏了什么吗?