当cmpw %ax -5x86-64的编码指令,来自Intel-instruction-set-reference-manual时,我有两个操作码可供选择:
3D iw CMP AX, imm16 I Valid Valid Compare imm16 with AX.
83 /7 ib CMP r/m16, imm8 MI Valid Valid Compare imm8 with r/m16.
Run Code Online (Sandbox Code Playgroud)
所以会有两个编码结果:
66 3d fb ff ; this for opcode 3d
66 83 f8 fb ; this for opcode 83
Run Code Online (Sandbox Code Playgroud)
那么哪一个更好?
我在下面尝试了一些在线反汇编程序
两者都可以反汇编到原点指令.但为什么6683fb00也有效,有效663dfb.
为什么gcc可以编译以下代码
#include <stdio.h>
int func();
int func(int a) { return 1; }
int main() {
func(10);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
但是,如果我补充一下char func();,gcc说conflicting types for ‘func’
我用来curl_easy_getinfo获取url,但有时它指向私有内存,我该如何解决?
102 bool bb_curl::check_result(CURLcode code, CURL *handle, bool check_url) {
103 if (code == CURLE_OK) {
104 char *url = nullptr;
105 auto rc = curl_easy_getinfo(handle, CURLINFO_EFFECTIVE_URL, &url);
106 if (rc == CURLE_OK && url && check_url) {
107 int http_code;
108 curl_easy_getinfo(handle, CURLINFO_RESPONSE_CODE, &http_code);
109 if (http_code == 200)
110 BB_VERBOSE("[OK] %s\n", url);
111 else
112 BB_Warn("[ERROR] http code:%d, url: %s\n", http_code, url);
113 }
Run Code Online (Sandbox Code Playgroud)
使用gdb:
Program received signal SIGSEGV, Segmentation fault.
(gdb) f 5 …Run Code Online (Sandbox Code Playgroud)