小编Ste*_*eve的帖子

x86指令编码如何选择操作码

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.

compiler-construction assembly x86-64 disassembly

5
推荐指数
1
解决办法
525
查看次数

可以声明两个具有相同名称的函数,返回类型但不同的参数

为什么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’

c gcc

4
推荐指数
1
解决办法
689
查看次数

libcurl 无法获取 CURLINFO_EFFECTIVE_URL

我用来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)

c c++ linux libcurl

3
推荐指数
1
解决办法
936
查看次数

标签 统计

c ×2

assembly ×1

c++ ×1

compiler-construction ×1

disassembly ×1

gcc ×1

libcurl ×1

linux ×1

x86-64 ×1