- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我有以下 C 源文件 hello.c,通过 g++ -o hello hello.c
在 linux 上编译:
#include <stdio.h>
const char* p = "Hello world";
const long nn = 0xDEADBEEF;
int main()
{
printf("%s %ld", p, nn);
return -1;
}
(是的,我知道我正在为 C 使用 g++,但这不是这个问题的重点。)
我想使用 readelf
或 objdump
查看常量整数 0xDEADBEEF
在二进制文件中的存储位置,但我没有知道命令开关来促进这一点。我可以使用这些工具清楚地看到我的字符串,但看不到整数。我已经尝试了各种命令选项,我不会在这里列出这些选项,因为它毫无意义,并且正在通过 grep 搜索 BEEF 来传输输出。
请问我需要什么命令行?
最佳答案
在计算中,字节顺序是指数字的二进制表示中字节(有时是位)的顺序。
在little endian 表示中,最后存储最高有效字节,而首先存储最低有效字节。所以在小端中,0xDEADBEEF
将被存储为 0xef 0xbe 0xad 0xde
。
然而,
在 big endian 中,首先存储最高有效字节,而最后存储最低有效字节。在大端中,0xDEADBEEF
将存储为 0xde 0xad 0xbe 0xef
。
.text
部分。
.data
部分。
.rodata
(只读数据)部分。
.text
部分。
为了
//#include <stdio.h>
const char* p = "Hello world";
int main()
{
const long nn = 0xDEADBEEF;
//printf("%s %ld", p, nn);
return -1;
}
编译时
gcc hello.c -o hello -nostdlib -e main
(使用 -nostdlib 来减小可执行文件的大小)
问候语内容如下:
Contents of section .interp:
0238 2f6c6962 36342f6c 642d6c69 6e75782d /lib64/ld-linux-
0248 7838362d 36342e73 6f2e3200 x86-64.so.2.
Contents of section .note.gnu.build-id:
0254 04000000 14000000 03000000 474e5500 ............GNU.
0264 45c5b659 336be965 5721226a 788a4906 E..Y3k.eW!"jx.I.
0274 d7528479 .R.y
Contents of section .gnu.hash:
0278 01000000 01000000 01000000 00000000 ................
0288 00000000 00000000 00000000 ............
Contents of section .dynsym:
0298 00000000 00000000 00000000 00000000 ................
02a8 00000000 00000000 ........
Contents of section .dynstr:
02b0 00 .
Contents of section .rela.dyn:
02b8 00102000 00000000 08000000 00000000 .. .............
02c8 e4020000 00000000 ........
Contents of section .text:
02d0 554889e5 b8efbead de488945 f8b8ffff UH.......H.E....
02e0 ffff5dc3 ..].
Contents of section .rodata:
02e4 48656c6c 6f20776f 726c6400 Hello world.
Contents of section .eh_frame_hdr:
02f0 011b033b 14000000 01000000 e0ffffff ...;............
0300 30000000 0...
Contents of section .eh_frame:
0308 14000000 00000000 017a5200 01781001 .........zR..x..
0318 1b0c0708 90010000 1c000000 1c000000 ................
0328 a8ffffff 14000000 00410e10 8602430d .........A....C.
0338 064f0c07 08000000 .O......
Contents of section .dynamic:
200ef0 f5feff6f 00000000 78020000 00000000 ...o....x.......
200f00 05000000 00000000 b0020000 00000000 ................
200f10 06000000 00000000 98020000 00000000 ................
200f20 0a000000 00000000 01000000 00000000 ................
200f30 0b000000 00000000 18000000 00000000 ................
200f40 15000000 00000000 00000000 00000000 ................
200f50 07000000 00000000 b8020000 00000000 ................
200f60 08000000 00000000 18000000 00000000 ................
200f70 09000000 00000000 18000000 00000000 ................
200f80 1e000000 00000000 08000000 00000000 ................
200f90 fbffff6f 00000000 01000008 00000000 ...o............
200fa0 f9ffff6f 00000000 01000000 00000000 ...o............
200fb0 00000000 00000000 00000000 00000000 ................
200fc0 00000000 00000000 00000000 00000000 ................
200fd0 00000000 00000000 00000000 00000000 ................
200fe0 00000000 00000000 00000000 00000000 ................
200ff0 00000000 00000000 00000000 00000000 ................
Contents of section .data:
201000 e4020000 00000000 ........
Contents of section .comment:
0000 4743433a 20285562 756e7475 20372e34 GCC: (Ubuntu 7.4
0010 2e302d31 7562756e 7475317e 31382e30 .0-1ubuntu1~18.0
0020 342e3129 20372e34 2e3000 4.1) 7.4.0.
您可以在 .text 部分的偏移量 02d5 处看到 little endian 中的 deadbeef。
阅读更多,
[1]字节顺序:https://en.wikipedia.org/wiki/Endianness
关于c - C 二进制中的整数 : viewing it using readelf, objdump 或类似,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58578591/
学习SQL。有一个简单的带有字段标题的桌面游戏。我想根据标题进行搜索。如果我有一款名为 Age of Empires III: Dynasties 的游戏,并且我使用 LIKE 和参数 Age of
我正在尝试为以下数据结构创建镜头。我正在使用lens-family . data Tree = Tree { _text :: String, _subtrees ::
我发现很难理解这一点。比如说,在 Python 中,如果我想要一个根据用户输入在循环中修改的列表,我会有这样的内容: def do_something(): x = [] while(
我有一个像这样的 mysql 查询 SELECT group_name FROM t_groups WHERE group_name LIKE '%PCB%'; 结果是 group_name ----
我的数据库表中有超过一百万条记录。当我使用like时非常慢,当我使用match against时他们丢失了一些记录。 我创建帮助表: 标签列表 tag_id tag_name tag_rel_me
我在我的一个 Java 项目中使用 JXBrowser 来简单显示 googlemaps 网页,以便我可以在那里跟踪路线,但最近我想改进该项目,但我的问题是 JXBrowser 的许可证过期(只有一个
小问题:如何将 mysql_escape_string 变量包含在 like 子句中? "SELECT * FROM table WHERE name LIKE '%". %s . "%'" 或
我尝试使用几个jquery消息插件,例如alertify . 但我注意到的主要事情是系统消息框会停止后台功能,直到用户响应。其他插件没有此功能。 有没有办法将此功能添加到 jquery 插件中?可以扩
我是 Ruby 新手。我过去使用过 shell。我正在将 shell 程序转换为 ruby。我有以下命令 cmd="cat -n " + infile + " | grep '127.0.0.1
关闭。这个问题不符合Stack Overflow guidelines .它目前不接受答案。 要求我们推荐或查找工具、库或最喜欢的场外资源的问题对于 Stack Overflow 来说是偏离主题的,
当我研究 Rust 时,我试图编写一个 Rust 函数来查看任何可迭代的字符串。 我最初的尝试是 fn example_1(iter: impl Iterator); fn example_2(ite
我必须在我的项目中使用代码拆分。但无论如何,第一次初始下载有一些代码。 现在我想向最终用户展示代码下载(.cache.html - 或其他代码拆分)的进度,例如 gmail 启动进度。 请你帮帮我。
我今天找到了一个错误,它最终是由我代码中的以下片段引起的(我试图在列表中仅过滤“PRIMARY KEY”约束): (filter #(= (% :constraint_type "PRIMARY KE
我正在尝试在关键字段上实现检查约束。关键字段由 3 个字符的前缀组成,然后附加数字字符(可以手动提供,但默认是从序列中获取整数值,然后将其转换为 nvarchar)。关键字段定义为 nvarhcar(
我正在尝试使用以下方式创建 List 实例: List listOne = new ArrayList(); List listTwo = new ArrayList(){}; List listTh
我过去曾为 iOS 开发过,最近转向了 mac 开发。我开始了一个“感受”事物的项目,但遇到了一个问题。我试图创建一个 NSTableView 来显示多个项目,包括一个标签、一个 2 UIImageV
我正在尝试编写一个查询,该查询将返回哪些主机缺少某个软件: Host Software A Title1 A
AFAIK,在三种情况下别名是可以的 仅限定符或符号不同的类型可以互为别名。 struct 或 union 类型可以为包含在其中的类型设置别名。 将 T* 转换为 char* 是可以的。 (不允许相反
\s 似乎不适用于 sed 's/[\s]\+//' tempfile 当它为工作时 sed 's/[ ]\+//' tempfile 我正在尝试删除由于命令而出现在每行开头的空格: nl -s ')
我正在使用 ocamlgraph 在 ocaml 中编写程序,并想知道是否要将其移植到 F# 我有哪些选择?谢谢。 最佳答案 QuickGraph .Net 最完整的图形库之一 关于F# 图形库(类似
我是一名优秀的程序员,十分优秀!