使用 memcpy 时数据重复
data repeats when using memcpy
我在 ubuntu 16.06
中使用 gcc
我正在尝试打开二进制文件并将其内容复制到缓冲区中。我看到复制的数据,但还有一些原来不存在的额外数据。对于终端的长输出,我深表歉意,但有必要说明我的问题。
如果我执行 hexdump -C binfile.bin
,这就是原始 binary.bin 显示的内容
00000000 fe ff ff ea fe ff ff ea fe ff ff ea fe ff ff ea |................|
*
00000020 66 55 99 aa 58 4e 4c 58 00 00 00 00 00 00 fc ff |fU..XNLX........|
00000030 00 28 00 00 00 00 00 00 00 00 00 00 e8 0c 01 00 |.(..............|
00000040 e8 0c 01 00 00 00 00 00 71 1a 1c fd 00 00 00 00 |........q.......|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 01 |............ ...|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000090 00 00 00 00 00 00 00 00 c0 08 00 00 00 11 00 00 |................|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000b0 00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 |................|
000000c0 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 00 |................|
*
000008b0 ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff |................|
000008c0 00 00 02 01 04 00 00 00 40 04 00 00 40 02 00 00 |........@...@...|
000008d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000008f0 00 00 00 00 00 00 00 00 00 00 00 00 7b f9 fd fe |............{...|
00000900 50 02 00 00 40 04 00 00 00 00 00 00 01 00 00 00 |P...@...........|
00000910 6c 62 73 66 73 65 74 5f 6c 65 2e 74 00 00 00 66 |lbsfset_le.t...f|
00000920 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000930 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000940 60 02 00 00 50 04 00 00 00 00 00 00 02 00 00 00 |`...P...........|
00000950 5f 66 6c 65 74 73 65 74 66 6c 65 2e 00 00 00 00 |_fletsetfle.....|
00000960 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000970 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000980 00 00 00 00 70 04 00 00 00 00 00 00 01 00 00 00 |....p...........|
00000990 74 73 79 73 77 5f 6d 65 70 70 61 72 62 2e 72 65 |tsysw_mepparb.re|
000009a0 00 00 74 69 00 00 00 00 ff ff ff ff ff ff ff ff |..ti............|
000009b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00001100 3a 43 00 00 3a 43 00 00 3a 43 00 00 50 04 00 00 |:C..:C..:C..P...|
这是 hexdump 在编译后显示的内容 $ objdump -s -j .data foo |更少
foo: file format elf64-little
Contents of section .data:
001e410 feffffea feffffea feffffea feffffea ................
001e420 feffffea feffffea feffffea feffffea ................
001e430 665599aa 584e4c58 00000000 0000fcff fU..XNLX........
001e440 00280000 00000000 00000000 e80c0100 .(..............
001e450 e80c0100 00000000 711a1cfd 00000000 ........q.......
001e460 00000000 00000000 00000000 00000000 ................
001e470 00000000 00000000 00000000 20000001 ............ ...
001e480 00000000 00000000 00000000 00000000 ................
001e490 00000000 00000000 00000000 00000000 ................
001e4a0 00000000 00000000 c0080000 00110000 ................
001e4b0 00000000 00000000 00000000 00000000 ................
001e4c0 00000000 00000000 ffffffff 00000000 ................
001e4d0 ffffffff 00000000 ffffffff 00000000 ................
001e4e0 ffffffff 00000000 ffffffff 00000000 ................
001e4f0 ffffffff 00000000 ffffffff 00000000 ................
001e500 ffffffff 00000000 ffffffff 00000000 ................
001e510 ffffffff 00000000 ffffffff 00000000 ................
001e520 ffffffff 00000000 ffffffff 00000000 ................
001e530 ffffffff 00000000 ffffffff 00000000 ................
001e540 ffffffff 00000000 ffffffff 00000000 ................
001e550 ffffffff 00000000 ffffffff 00000000 ................
001e560 ffffffff 00000000 ffffffff 00000000 ................
001e570 ffffffff 00000000 ffffffff 00000000 ................
001e580 ffffffff 00000000 ffffffff 00000000 ................
001e590 ffffffff 00000000 ffffffff 00000000 ................
001e5a0 ffffffff 00000000 ffffffff 00000000 ................
001e5b0 ffffffff 00000000 ffffffff 00000000 ................
001e5c0 ffffffff 00000000 ffffffff 00000000 ................
001e5d0 ffffffff 00000000 ffffffff 00000000 ................
001e5e0 ffffffff 00000000 ffffffff 00000000 ................
001e5f0 ffffffff 00000000 ffffffff 00000000 ................
001e600 ffffffff 00000000 ffffffff 00000000 ................
001e610 ffffffff 00000000 ffffffff 00000000 ................
001e620 ffffffff 00000000 ffffffff 00000000 ................
001e630 ffffffff 00000000 ffffffff 00000000 ................
001e640 ffffffff 00000000 ffffffff 00000000 ................
001e650 ffffffff 00000000 ffffffff 00000000 ................
001e660 ffffffff 00000000 ffffffff 00000000 ................
001e670 ffffffff 00000000 ffffffff 00000000 ................
001e680 ffffffff 00000000 ffffffff 00000000 ................
001e690 ffffffff 00000000 ffffffff 00000000 ................
001e6a0 ffffffff 00000000 ffffffff 00000000 ................
001e6b0 ffffffff 00000000 ffffffff 00000000 ................
001e6c0 ffffffff 00000000 ffffffff 00000000 ................
001e6d0 ffffffff 00000000 ffffffff 00000000 ................
001e6e0 ffffffff 00000000 ffffffff 00000000 ................
001e6f0 ffffffff 00000000 ffffffff 00000000 ................
001e700 ffffffff 00000000 ffffffff 00000000 ................
001e710 ffffffff 00000000 ffffffff 00000000 ................
001e720 ffffffff 00000000 ffffffff 00000000 ................
001e730 ffffffff 00000000 ffffffff 00000000 ................
001e740 ffffffff 00000000 ffffffff 00000000 ................
001e750 ffffffff 00000000 ffffffff 00000000 ................
001e760 ffffffff 00000000 ffffffff 00000000 ................
001e770 ffffffff 00000000 ffffffff 00000000 ................
001e780 ffffffff 00000000 ffffffff 00000000 ................
001e790 ffffffff 00000000 ffffffff 00000000 ................
001e7a0 ffffffff 00000000 ffffffff 00000000 ................
001e7b0 ffffffff 00000000 ffffffff 00000000 ................
001e7c0 ffffffff 00000000 ffffffff 00000000 ................
001e7d0 ffffffff 00000000 ffffffff 00000000 ................
001e7e0 ffffffff 00000000 ffffffff 00000000 ................
001e7f0 ffffffff 00000000 ffffffff 00000000 ................
001e800 ffffffff 00000000 ffffffff 00000000 ................
001e810 ffffffff 00000000 ffffffff 00000000 ................
001e820 ffffffff 00000000 ffffffff 00000000 ................
001e830 ffffffff 00000000 ffffffff 00000000 ................
001e840 ffffffff 00000000 ffffffff 00000000 ................
001e850 ffffffff 00000000 ffffffff 00000000 ................
001e860 ffffffff 00000000 ffffffff 00000000 ................
001e870 ffffffff 00000000 ffffffff 00000000 ................
001e880 ffffffff 00000000 ffffffff 00000000 ................
001e890 ffffffff 00000000 ffffffff 00000000 ................
001e8a0 ffffffff 00000000 ffffffff 00000000 ................
001e8b0 ffffffff 00000000 ffffffff 00000000 ................
001e8c0 ffffffff 00000000 ffffffff 00000000 ................
001e8d0 ffffffff 00000000 ffffffff 00000000 ................
001e8e0 ffffffff 00000000 ffffffff 00000000 ................
001e8f0 ffffffff 00000000 ffffffff 00000000 ................
001e900 ffffffff 00000000 ffffffff 00000000 ................
001e910 ffffffff 00000000 ffffffff 00000000 ................
001e920 ffffffff 00000000 ffffffff 00000000 ................
001e930 ffffffff 00000000 ffffffff 00000000 ................
001e940 ffffffff 00000000 ffffffff 00000000 ................
001e950 ffffffff 00000000 ffffffff 00000000 ................
001e960 ffffffff 00000000 ffffffff 00000000 ................
001e970 ffffffff 00000000 ffffffff 00000000 ................
001e980 ffffffff 00000000 ffffffff 00000000 ................
001e990 ffffffff 00000000 ffffffff 00000000 ................
001e9a0 ffffffff 00000000 ffffffff 00000000 ................
001e9b0 ffffffff 00000000 ffffffff 00000000 ................
001e9c0 ffffffff 00000000 ffffffff 00000000 ................
001e9d0 ffffffff 00000000 ffffffff 00000000 ................
001e9e0 ffffffff 00000000 ffffffff 00000000 ................
001e9f0 ffffffff 00000000 ffffffff 00000000 ................
001ea00 ffffffff 00000000 ffffffff 00000000 ................
001ea10 ffffffff 00000000 ffffffff 00000000 ................
001ea20 ffffffff 00000000 ffffffff 00000000 ................
001ea30 ffffffff 00000000 ffffffff 00000000 ................
001ea40 ffffffff 00000000 ffffffff 00000000 ................
001ea50 ffffffff 00000000 ffffffff 00000000 ................
001ea60 ffffffff 00000000 ffffffff 00000000 ................
001ea70 ffffffff 00000000 ffffffff 00000000 ................
001ea80 ffffffff 00000000 ffffffff 00000000 ................
001ea90 ffffffff 00000000 ffffffff 00000000 ................
001eaa0 ffffffff 00000000 ffffffff 00000000 ................
001...........eab0 ffffffff 00000000 ffffffff 00000000 ................
001eac0 ffffffff 00000000 ffffffff 00000000 ................
001ead0 ffffffff 00000000 ffffffff 00000000 ................
001eae0 ffffffff 00000000 ffffffff 00000000 ................
001eaf0 ffffffff 00000000 ffffffff 00000000 ................
001eb00 ffffffff 00000000 ffffffff 00000000 ................
001eb10 ffffffff 00000000 ffffffff 00000000 ................
001eb20 ffffffff 00000000 ffffffff 00000000 ................
001eb30 ffffffff 00000000 ffffffff 00000000 ................
001eb40 ffffffff 00000000 ffffffff 00000000 ................
001eb50 ffffffff 00000000 ffffffff 00000000 ................
001eb60 ffffffff 00000000 ffffffff 00000000 ................
001eb70 ffffffff 00000000 ffffffff 00000000 ................
001eb80 ffffffff 00000000 ffffffff 00000000 ................
001eb90 ffffffff 00000000 ffffffff 00000000 ................
001eba0 ffffffff 00000000 ffffffff 00000000 ................
001ebb0 ffffffff 00000000 ffffffff 00000000 ................
001ebc0 ffffffff 00000000 ffffffff 00000000 ................
001ebd0 ffffffff 00000000 ffffffff 00000000 ................
001ebe0 ffffffff 00000000 ffffffff 00000000 ................
001ebf0 ffffffff 00000000 ffffffff 00000000 ................
001ec00 ffffffff 00000000 ffffffff 00000000 ................
001ec10 ffffffff 00000000 ffffffff 00000000 ................
001ec20 ffffffff 00000000 ffffffff 00000000 ................
001ec30 ffffffff 00000000 ffffffff 00000000 ................
001ec40 ffffffff 00000000 ffffffff 00000000 ................
001ec50 ffffffff 00000000 ffffffff 00000000 ................
001ec60 ffffffff 00000000 ffffffff 00000000 ................
001ec70 ffffffff 00000000 ffffffff 00000000 ................
001ec80 ffffffff 00000000 ffffffff 00000000 ................
001ec90 ffffffff 00000000 ffffffff 00000000 ................
001eca0 ffffffff 00000000 ffffffff 00000000 ................
001ecb0 ffffffff 00000000 ffffffff 00000000 ................
001ecc0 ffffffff 00000000 ffffffff ffffffff ................
001ecd0 00000201 04000000 40040000 40020000 ........@...@...
001ece0 00000000 00000000 00000000 00000000 ................
001ecf0 00000000 00000000 00000000 00000000 ................
001ed00 00000000 00000000 00000000 7bf9fdfe ............{...
001ed10 50020000 40040000 00000000 01000000 P...@...........
001ed20 6c627366 7365745f 6c652e74 00000066 lbsfset_le.t...f
001ed30 00000000 ffffffff ffffffff ffffffff ................
001ed40 ffffffff ffffffff ffffffff ffffffff ................
001ed50 60020000 50040000 00000000 02000000 `...P...........
001ed60 5f666c65 74736574 666c652e 00000000 _fletsetfle.....
001ed70 00000000 ffffffff ffffffff ffffffff ................
001ed80 ffffffff ffffffff ffffffff ffffffff ................
001ed90 00000000 70040000 00000000 01000000 ....p...........
001eda0 74737973 775f6d65 70706172 622e7265 tsysw_mepparb.re
001edb0 00007469 00000000 ffffffff ffffffff ..ti............
001edc0 ffffffff ffffffff ffffffff ffffffff ................
001edd0 ffffffff ffffffff ffffffff ffffffff ................
001ede0 ffffffff ffffffff ffffffff ffffffff ................
001edf0 ffffffff ffffffff ffffffff ffffffff ................
001ee00 ffffffff ffffffff ffffffff ffffffff ................
001ee10 ffffffff ffffffff ffffffff ffffffff ................
001ee20 ffffffff ffffffff ffffffff ffffffff ................
001ee30 ffffffff ffffffff ffffffff ffffffff ................
001ee40 ffffffff ffffffff ffffffff ffffffff ................
001ee50 ffffffff ffffffff ffffffff ffffffff ................
001ee60 ffffffff ffffffff ffffffff ffffffff ................
001ee70 ffffffff ffffffff ffffffff ffffffff ................
001ee80 ffffffff ffffffff ffffffff ffffffff ................
001ee90 ffffffff ffffffff ffffffff ffffffff ................
001eea0 ffffffff ffffffff ffffffff ffffffff ................
001eeb0 ffffffff ffffffff ffffffff ffffffff ................
001eec0 ffffffff ffffffff ffffffff ffffffff ................
001eed0 ffffffff ffffffff ffffffff ffffffff ................
001eee0 ffffffff ffffffff ffffffff ffffffff ................
001eef0 ffffffff ffffffff ffffffff ffffffff ................
001ef00 ffffffff ffffffff ffffffff ffffffff ................
001ef10 ffffffff ffffffff ffffffff ffffffff ................
001ef20 ffffffff ffffffff ffffffff ffffffff ................
001ef30 ffffffff ffffffff ffffffff ffffffff ................
001ef40 ffffffff ffffffff ffffffff ffffffff ................
001ef50 ffffffff ffffffff ffffffff ffffffff ................
001ef60 ffffffff ffffffff ffffffff ffffffff ................
001ef70 ffffffff ffffffff ffffffff ffffffff ................
001ef80 ffffffff ffffffff ffffffff ffffffff ................
001ef90 ffffffff ffffffff ffffffff ffffffff ................
001efa0 ffffffff ffffffff ffffffff ffffffff ................
001efb0 ffffffff ffffffff ffffffff ffffffff ................
001efc0 ffffffff ffffffff ffffffff ffffffff ................
001efd0 ffffffff ffffffff ffffffff ffffffff ................
001efe0 ffffffff ffffffff ffffffff ffffffff ................
001eff0 ffffffff ffffffff ffffffff ffffffff ................
001f000 ffffffff ffffffff ffffffff ffffffff ................
001f010 ffffffff ffffffff ffffffff ffffffff ................
001f020 ffffffff ffffffff ffffffff ffffffff ................
001ef30 ffffffff ffffffff ffffffff ffffffff ................
001ef40 ffffffff ffffffff ffffffff ffffffff ................
001ef50 ffffffff ffffffff ffffffff ffffffff ................
001ef60 ffffffff ffffffff ffffffff ffffffff ................
001ef70 ffffffff ffffffff ffffffff ffffffff ................
001ef80 ffffffff ffffffff ffffffff ffffffff ................
001ef90 ffffffff ffffffff ffffffff ffffffff ................
001efa0 ffffffff ffffffff ffffffff ffffffff ................
001efb0 ffffffff ffffffff ffffffff ffffffff ................
001efc0 ffffffff ffffffff ffffffff ffffffff ................
001efd0 ffffffff ffffffff ffffffff ffffffff ................
001efe0 ffffffff ffffffff ffffffff ffffffff ................
001eff0 ffffffff ffffffff ffffffff ffffffff ................
001f000 ffffffff ffffffff ffffffff ffffffff ................
001f010 ffffffff ffffffff ffffffff ffffffff ................
001f020 ffffffff ffffffff ffffffff ffffffff ................
001f030 ffffffff ffffffff ffffffff ffffffff ................
001f040 ffffffff ffffffff ffffffff ffffffff ................
001f050 ffffffff ffffffff ffffffff ffffffff ................
001f060 ffffffff ffffffff ffffffff ffffffff ................
001f070 ffffffff ffffffff ffffffff ffffffff ................
001f080 ffffffff ffffffff ffffffff ffffffff ................
001f090 ffffffff ffffffff ffffffff ffffffff ................
001f0a0 ffffffff ffffffff ffffffff ffffffff ................
001f0b0 ffffffff ffffffff ffffffff ffffffff ................
001f0c0 ffffffff ffffffff ffffffff ffffffff ................
001f0d0 ffffffff ffffffff ffffffff ffffffff ................
001f0e0 ffffffff ffffffff ffffffff ffffffff ................
001f0f0 ffffffff ffffffff ffffffff ffffffff ................
001f100 ffffffff ffffffff ffffffff ffffffff ................
001f110 ffffffff ffffffff ffffffff ffffffff ................
001f120 ffffffff ffffffff ffffffff ffffffff ................
001f130 ffffffff ffffffff ffffffff ffffffff ................
001f140 ffffffff ffffffff ffffffff ffffffff ................
001f150 ffffffff ffffffff ffffffff ffffffff ................
001f160 ffffffff ffffffff ffffffff ffffffff ................
001f170 ffffffff ffffffff ffffffff ffffffff ................
001f180 ffffffff ffffffff ffffffff ffffffff ................
001f190 ffffffff ffffffff ffffffff ffffffff ................
001f1a0 ffffffff ffffffff ffffffff ffffffff ................
001f1b0 ffffffff ffffffff ffffffff ffffffff ................
001f1c0 ffffffff ffffffff ffffffff ffffffff ................
001f1d0 ffffffff ffffffff ffffffff ffffffff ................
001f1e0 ffffffff ffffffff ffffffff ffffffff ................
001f1f0 ffffffff ffffffff ffffffff ffffffff ................
001f200 ffffffff ffffffff ffffffff ffffffff ................
001f210 ffffffff ffffffff ffffffff ffffffff ................
001f220 ffffffff ffffffff ffffffff ffffffff ................
001f230 ffffffff ffffffff ffffffff ffffffff ................
001f240 ffffffff ffffffff ffffffff ffffffff ................
001f250 ffffffff ffffffff ffffffff ffffffff ................
001f260 ffffffff ffffffff ffffffff ffffffff ................
001f270 ffffffff ffffffff ffffffff ffffffff ................
001f280 ffffffff ffffffff ffffffff ffffffff ................
001f290 ffffffff ffffffff ffffffff ffffffff ................
001f2a0 ffffffff ffffffff ffffffff ffffffff ................
001f2b0 ffffffff ffffffff ffffffff ffffffff ................
001f2c0 ffffffff ffffffff ffffffff ffffffff ................
001f2d0 ffffffff ffffffff ffffffff ffffffff ................
001f2e0 ffffffff ffffffff ffffffff ffffffff ................
001f2f0 ffffffff ffffffff ffffffff ffffffff ................
001f300 ffffffff ffffffff ffffffff ffffffff ................
001f310 ffffffff ffffffff ffffffff ffffffff ................
001f320 ffffffff ffffffff ffffffff ffffffff ................
001f330 ffffffff ffffffff ffffffff ffffffff ................
001f340 ffffffff ffffffff ffffffff ffffffff ................
001f350 ffffffff ffffffff ffffffff ffffffff ................
001f360 ffffffff ffffffff ffffffff ffffffff ................
001f370 ffffffff ffffffff ffffffff ffffffff ................
001f380 ffffffff ffffffff ffffffff ffffffff ................
001f390 ffffffff ffffffff ffffffff ffffffff ................
001f3a0 ffffffff ffffffff ffffffff ffffffff ................
001f3b0 ffffffff ffffffff ffffffff ffffffff ................
001f3c0 ffffffff ffffffff ffffffff ffffffff ................
001f3d0 ffffffff ffffffff ffffffff ffffffff ................
001f3e0 ffffffff ffffffff ffffffff ffffffff ................
001f3f0 ffffffff ffffffff ffffffff ffffffff ................
001f400 ffffffff ffffffff ffffffff ffffffff ................
001f410 ffffffff ffffffff ffffffff ffffffff ................
001f420 ffffffff ffffffff ffffffff ffffffff ................
001f430 ffffffff ffffffff ffffffff ffffffff ................
001f440 ffffffff ffffffff ffffffff ffffffff ................
001f450 ffffffff ffffffff ffffffff ffffffff ................
001f460 ffffffff ffffffff ffffffff ffffffff ................
001f470 ffffffff ffffffff ffffffff ffffffff ................
001f480 ffffffff ffffffff ffffffff ffffffff ................
001f490 ffffffff ffffffff ffffffff ffffffff ................
001f4a0 ffffffff ffffffff ffffffff ffffffff ................
001f4b0 ffffffff ffffffff ffffffff ffffffff ................
001f4c0 ffffffff ffffffff ffffffff ffffffff ................
001f4d0 ffffffff ffffffff ffffffff ffffffff ................
001f4e0 ffffffff ffffffff ffffffff ffffffff ................
001f4f0 ffffffff ffffffff ffffffff ffffffff ................
001f500 ffffffff ffffffff ffffffff ffffffff ................
001f510 3a430000 3a430000 3a430000 50040000 :C..:C..:C..P...
这是我的相关代码
#define bsize (10000)
uint8_t write_buffer[bsize];
uint8_t read_buffer[bsize];
int main()
{
FILE *pttr;
pttr = fopen("binfile.bin", "rb");
if(!pttr)
{
printf("unable to open file");
return USP_FAILURE;
}
fseek(pttr, 0, SEEK_END);
rewind(pttr);
fread(read_buffer, sizeof(read_buffer), 1,pttr);
memcpy(write_buffer, read_buffer, sizeof(read_buffer));
int i;
for (i = 0; i < sizeof write_buffer; i++)
{
printf("%02x ", write_buffer[i] & 0xFF);
}
//printf("\n\n");
fclose(pttr);
return 1;
}
我的二进制文件和 objdump 的输出要大得多,额外的数据沿着 .data 部分的其余部分重复。此外,我的 printf 的输出与 obdump 命令的输出相同,因此我没有包含它。我会很感激任何建议。
附加数据实际上存在于原始文件中。查看 hexdump 中的这些行:
000000c0 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 00 |................|
*
000008b0 ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff |................|
您会注意到文件偏移量的第一列有一个很大的跳跃。仅包含 *
的行表示重复前一行直到下一行的偏移量。
如果您使用 -v
选项再次 运行 hexdump,它将打印所有输入行,您应该会看到它与您的输出匹配。
我在 ubuntu 16.06
中使用 gcc我正在尝试打开二进制文件并将其内容复制到缓冲区中。我看到复制的数据,但还有一些原来不存在的额外数据。对于终端的长输出,我深表歉意,但有必要说明我的问题。
如果我执行 hexdump -C binfile.bin
,这就是原始 binary.bin 显示的内容00000000 fe ff ff ea fe ff ff ea fe ff ff ea fe ff ff ea |................|
*
00000020 66 55 99 aa 58 4e 4c 58 00 00 00 00 00 00 fc ff |fU..XNLX........|
00000030 00 28 00 00 00 00 00 00 00 00 00 00 e8 0c 01 00 |.(..............|
00000040 e8 0c 01 00 00 00 00 00 71 1a 1c fd 00 00 00 00 |........q.......|
00000050 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
00000060 00 00 00 00 00 00 00 00 00 00 00 00 20 00 00 01 |............ ...|
00000070 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
00000090 00 00 00 00 00 00 00 00 c0 08 00 00 00 11 00 00 |................|
000000a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
000000b0 00 00 00 00 00 00 00 00 ff ff ff ff 00 00 00 00 |................|
000000c0 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 00 |................|
*
000008b0 ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff |................|
000008c0 00 00 02 01 04 00 00 00 40 04 00 00 40 02 00 00 |........@...@...|
000008d0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................|
*
000008f0 00 00 00 00 00 00 00 00 00 00 00 00 7b f9 fd fe |............{...|
00000900 50 02 00 00 40 04 00 00 00 00 00 00 01 00 00 00 |P...@...........|
00000910 6c 62 73 66 73 65 74 5f 6c 65 2e 74 00 00 00 66 |lbsfset_le.t...f|
00000920 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000930 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000940 60 02 00 00 50 04 00 00 00 00 00 00 02 00 00 00 |`...P...........|
00000950 5f 66 6c 65 74 73 65 74 66 6c 65 2e 00 00 00 00 |_fletsetfle.....|
00000960 00 00 00 00 ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000970 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
00000980 00 00 00 00 70 04 00 00 00 00 00 00 01 00 00 00 |....p...........|
00000990 74 73 79 73 77 5f 6d 65 70 70 61 72 62 2e 72 65 |tsysw_mepparb.re|
000009a0 00 00 74 69 00 00 00 00 ff ff ff ff ff ff ff ff |..ti............|
000009b0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
*
00001100 3a 43 00 00 3a 43 00 00 3a 43 00 00 50 04 00 00 |:C..:C..:C..P...|
这是 hexdump 在编译后显示的内容 $ objdump -s -j .data foo |更少
foo: file format elf64-little
Contents of section .data:
001e410 feffffea feffffea feffffea feffffea ................
001e420 feffffea feffffea feffffea feffffea ................
001e430 665599aa 584e4c58 00000000 0000fcff fU..XNLX........
001e440 00280000 00000000 00000000 e80c0100 .(..............
001e450 e80c0100 00000000 711a1cfd 00000000 ........q.......
001e460 00000000 00000000 00000000 00000000 ................
001e470 00000000 00000000 00000000 20000001 ............ ...
001e480 00000000 00000000 00000000 00000000 ................
001e490 00000000 00000000 00000000 00000000 ................
001e4a0 00000000 00000000 c0080000 00110000 ................
001e4b0 00000000 00000000 00000000 00000000 ................
001e4c0 00000000 00000000 ffffffff 00000000 ................
001e4d0 ffffffff 00000000 ffffffff 00000000 ................
001e4e0 ffffffff 00000000 ffffffff 00000000 ................
001e4f0 ffffffff 00000000 ffffffff 00000000 ................
001e500 ffffffff 00000000 ffffffff 00000000 ................
001e510 ffffffff 00000000 ffffffff 00000000 ................
001e520 ffffffff 00000000 ffffffff 00000000 ................
001e530 ffffffff 00000000 ffffffff 00000000 ................
001e540 ffffffff 00000000 ffffffff 00000000 ................
001e550 ffffffff 00000000 ffffffff 00000000 ................
001e560 ffffffff 00000000 ffffffff 00000000 ................
001e570 ffffffff 00000000 ffffffff 00000000 ................
001e580 ffffffff 00000000 ffffffff 00000000 ................
001e590 ffffffff 00000000 ffffffff 00000000 ................
001e5a0 ffffffff 00000000 ffffffff 00000000 ................
001e5b0 ffffffff 00000000 ffffffff 00000000 ................
001e5c0 ffffffff 00000000 ffffffff 00000000 ................
001e5d0 ffffffff 00000000 ffffffff 00000000 ................
001e5e0 ffffffff 00000000 ffffffff 00000000 ................
001e5f0 ffffffff 00000000 ffffffff 00000000 ................
001e600 ffffffff 00000000 ffffffff 00000000 ................
001e610 ffffffff 00000000 ffffffff 00000000 ................
001e620 ffffffff 00000000 ffffffff 00000000 ................
001e630 ffffffff 00000000 ffffffff 00000000 ................
001e640 ffffffff 00000000 ffffffff 00000000 ................
001e650 ffffffff 00000000 ffffffff 00000000 ................
001e660 ffffffff 00000000 ffffffff 00000000 ................
001e670 ffffffff 00000000 ffffffff 00000000 ................
001e680 ffffffff 00000000 ffffffff 00000000 ................
001e690 ffffffff 00000000 ffffffff 00000000 ................
001e6a0 ffffffff 00000000 ffffffff 00000000 ................
001e6b0 ffffffff 00000000 ffffffff 00000000 ................
001e6c0 ffffffff 00000000 ffffffff 00000000 ................
001e6d0 ffffffff 00000000 ffffffff 00000000 ................
001e6e0 ffffffff 00000000 ffffffff 00000000 ................
001e6f0 ffffffff 00000000 ffffffff 00000000 ................
001e700 ffffffff 00000000 ffffffff 00000000 ................
001e710 ffffffff 00000000 ffffffff 00000000 ................
001e720 ffffffff 00000000 ffffffff 00000000 ................
001e730 ffffffff 00000000 ffffffff 00000000 ................
001e740 ffffffff 00000000 ffffffff 00000000 ................
001e750 ffffffff 00000000 ffffffff 00000000 ................
001e760 ffffffff 00000000 ffffffff 00000000 ................
001e770 ffffffff 00000000 ffffffff 00000000 ................
001e780 ffffffff 00000000 ffffffff 00000000 ................
001e790 ffffffff 00000000 ffffffff 00000000 ................
001e7a0 ffffffff 00000000 ffffffff 00000000 ................
001e7b0 ffffffff 00000000 ffffffff 00000000 ................
001e7c0 ffffffff 00000000 ffffffff 00000000 ................
001e7d0 ffffffff 00000000 ffffffff 00000000 ................
001e7e0 ffffffff 00000000 ffffffff 00000000 ................
001e7f0 ffffffff 00000000 ffffffff 00000000 ................
001e800 ffffffff 00000000 ffffffff 00000000 ................
001e810 ffffffff 00000000 ffffffff 00000000 ................
001e820 ffffffff 00000000 ffffffff 00000000 ................
001e830 ffffffff 00000000 ffffffff 00000000 ................
001e840 ffffffff 00000000 ffffffff 00000000 ................
001e850 ffffffff 00000000 ffffffff 00000000 ................
001e860 ffffffff 00000000 ffffffff 00000000 ................
001e870 ffffffff 00000000 ffffffff 00000000 ................
001e880 ffffffff 00000000 ffffffff 00000000 ................
001e890 ffffffff 00000000 ffffffff 00000000 ................
001e8a0 ffffffff 00000000 ffffffff 00000000 ................
001e8b0 ffffffff 00000000 ffffffff 00000000 ................
001e8c0 ffffffff 00000000 ffffffff 00000000 ................
001e8d0 ffffffff 00000000 ffffffff 00000000 ................
001e8e0 ffffffff 00000000 ffffffff 00000000 ................
001e8f0 ffffffff 00000000 ffffffff 00000000 ................
001e900 ffffffff 00000000 ffffffff 00000000 ................
001e910 ffffffff 00000000 ffffffff 00000000 ................
001e920 ffffffff 00000000 ffffffff 00000000 ................
001e930 ffffffff 00000000 ffffffff 00000000 ................
001e940 ffffffff 00000000 ffffffff 00000000 ................
001e950 ffffffff 00000000 ffffffff 00000000 ................
001e960 ffffffff 00000000 ffffffff 00000000 ................
001e970 ffffffff 00000000 ffffffff 00000000 ................
001e980 ffffffff 00000000 ffffffff 00000000 ................
001e990 ffffffff 00000000 ffffffff 00000000 ................
001e9a0 ffffffff 00000000 ffffffff 00000000 ................
001e9b0 ffffffff 00000000 ffffffff 00000000 ................
001e9c0 ffffffff 00000000 ffffffff 00000000 ................
001e9d0 ffffffff 00000000 ffffffff 00000000 ................
001e9e0 ffffffff 00000000 ffffffff 00000000 ................
001e9f0 ffffffff 00000000 ffffffff 00000000 ................
001ea00 ffffffff 00000000 ffffffff 00000000 ................
001ea10 ffffffff 00000000 ffffffff 00000000 ................
001ea20 ffffffff 00000000 ffffffff 00000000 ................
001ea30 ffffffff 00000000 ffffffff 00000000 ................
001ea40 ffffffff 00000000 ffffffff 00000000 ................
001ea50 ffffffff 00000000 ffffffff 00000000 ................
001ea60 ffffffff 00000000 ffffffff 00000000 ................
001ea70 ffffffff 00000000 ffffffff 00000000 ................
001ea80 ffffffff 00000000 ffffffff 00000000 ................
001ea90 ffffffff 00000000 ffffffff 00000000 ................
001eaa0 ffffffff 00000000 ffffffff 00000000 ................
001...........eab0 ffffffff 00000000 ffffffff 00000000 ................
001eac0 ffffffff 00000000 ffffffff 00000000 ................
001ead0 ffffffff 00000000 ffffffff 00000000 ................
001eae0 ffffffff 00000000 ffffffff 00000000 ................
001eaf0 ffffffff 00000000 ffffffff 00000000 ................
001eb00 ffffffff 00000000 ffffffff 00000000 ................
001eb10 ffffffff 00000000 ffffffff 00000000 ................
001eb20 ffffffff 00000000 ffffffff 00000000 ................
001eb30 ffffffff 00000000 ffffffff 00000000 ................
001eb40 ffffffff 00000000 ffffffff 00000000 ................
001eb50 ffffffff 00000000 ffffffff 00000000 ................
001eb60 ffffffff 00000000 ffffffff 00000000 ................
001eb70 ffffffff 00000000 ffffffff 00000000 ................
001eb80 ffffffff 00000000 ffffffff 00000000 ................
001eb90 ffffffff 00000000 ffffffff 00000000 ................
001eba0 ffffffff 00000000 ffffffff 00000000 ................
001ebb0 ffffffff 00000000 ffffffff 00000000 ................
001ebc0 ffffffff 00000000 ffffffff 00000000 ................
001ebd0 ffffffff 00000000 ffffffff 00000000 ................
001ebe0 ffffffff 00000000 ffffffff 00000000 ................
001ebf0 ffffffff 00000000 ffffffff 00000000 ................
001ec00 ffffffff 00000000 ffffffff 00000000 ................
001ec10 ffffffff 00000000 ffffffff 00000000 ................
001ec20 ffffffff 00000000 ffffffff 00000000 ................
001ec30 ffffffff 00000000 ffffffff 00000000 ................
001ec40 ffffffff 00000000 ffffffff 00000000 ................
001ec50 ffffffff 00000000 ffffffff 00000000 ................
001ec60 ffffffff 00000000 ffffffff 00000000 ................
001ec70 ffffffff 00000000 ffffffff 00000000 ................
001ec80 ffffffff 00000000 ffffffff 00000000 ................
001ec90 ffffffff 00000000 ffffffff 00000000 ................
001eca0 ffffffff 00000000 ffffffff 00000000 ................
001ecb0 ffffffff 00000000 ffffffff 00000000 ................
001ecc0 ffffffff 00000000 ffffffff ffffffff ................
001ecd0 00000201 04000000 40040000 40020000 ........@...@...
001ece0 00000000 00000000 00000000 00000000 ................
001ecf0 00000000 00000000 00000000 00000000 ................
001ed00 00000000 00000000 00000000 7bf9fdfe ............{...
001ed10 50020000 40040000 00000000 01000000 P...@...........
001ed20 6c627366 7365745f 6c652e74 00000066 lbsfset_le.t...f
001ed30 00000000 ffffffff ffffffff ffffffff ................
001ed40 ffffffff ffffffff ffffffff ffffffff ................
001ed50 60020000 50040000 00000000 02000000 `...P...........
001ed60 5f666c65 74736574 666c652e 00000000 _fletsetfle.....
001ed70 00000000 ffffffff ffffffff ffffffff ................
001ed80 ffffffff ffffffff ffffffff ffffffff ................
001ed90 00000000 70040000 00000000 01000000 ....p...........
001eda0 74737973 775f6d65 70706172 622e7265 tsysw_mepparb.re
001edb0 00007469 00000000 ffffffff ffffffff ..ti............
001edc0 ffffffff ffffffff ffffffff ffffffff ................
001edd0 ffffffff ffffffff ffffffff ffffffff ................
001ede0 ffffffff ffffffff ffffffff ffffffff ................
001edf0 ffffffff ffffffff ffffffff ffffffff ................
001ee00 ffffffff ffffffff ffffffff ffffffff ................
001ee10 ffffffff ffffffff ffffffff ffffffff ................
001ee20 ffffffff ffffffff ffffffff ffffffff ................
001ee30 ffffffff ffffffff ffffffff ffffffff ................
001ee40 ffffffff ffffffff ffffffff ffffffff ................
001ee50 ffffffff ffffffff ffffffff ffffffff ................
001ee60 ffffffff ffffffff ffffffff ffffffff ................
001ee70 ffffffff ffffffff ffffffff ffffffff ................
001ee80 ffffffff ffffffff ffffffff ffffffff ................
001ee90 ffffffff ffffffff ffffffff ffffffff ................
001eea0 ffffffff ffffffff ffffffff ffffffff ................
001eeb0 ffffffff ffffffff ffffffff ffffffff ................
001eec0 ffffffff ffffffff ffffffff ffffffff ................
001eed0 ffffffff ffffffff ffffffff ffffffff ................
001eee0 ffffffff ffffffff ffffffff ffffffff ................
001eef0 ffffffff ffffffff ffffffff ffffffff ................
001ef00 ffffffff ffffffff ffffffff ffffffff ................
001ef10 ffffffff ffffffff ffffffff ffffffff ................
001ef20 ffffffff ffffffff ffffffff ffffffff ................
001ef30 ffffffff ffffffff ffffffff ffffffff ................
001ef40 ffffffff ffffffff ffffffff ffffffff ................
001ef50 ffffffff ffffffff ffffffff ffffffff ................
001ef60 ffffffff ffffffff ffffffff ffffffff ................
001ef70 ffffffff ffffffff ffffffff ffffffff ................
001ef80 ffffffff ffffffff ffffffff ffffffff ................
001ef90 ffffffff ffffffff ffffffff ffffffff ................
001efa0 ffffffff ffffffff ffffffff ffffffff ................
001efb0 ffffffff ffffffff ffffffff ffffffff ................
001efc0 ffffffff ffffffff ffffffff ffffffff ................
001efd0 ffffffff ffffffff ffffffff ffffffff ................
001efe0 ffffffff ffffffff ffffffff ffffffff ................
001eff0 ffffffff ffffffff ffffffff ffffffff ................
001f000 ffffffff ffffffff ffffffff ffffffff ................
001f010 ffffffff ffffffff ffffffff ffffffff ................
001f020 ffffffff ffffffff ffffffff ffffffff ................
001ef30 ffffffff ffffffff ffffffff ffffffff ................
001ef40 ffffffff ffffffff ffffffff ffffffff ................
001ef50 ffffffff ffffffff ffffffff ffffffff ................
001ef60 ffffffff ffffffff ffffffff ffffffff ................
001ef70 ffffffff ffffffff ffffffff ffffffff ................
001ef80 ffffffff ffffffff ffffffff ffffffff ................
001ef90 ffffffff ffffffff ffffffff ffffffff ................
001efa0 ffffffff ffffffff ffffffff ffffffff ................
001efb0 ffffffff ffffffff ffffffff ffffffff ................
001efc0 ffffffff ffffffff ffffffff ffffffff ................
001efd0 ffffffff ffffffff ffffffff ffffffff ................
001efe0 ffffffff ffffffff ffffffff ffffffff ................
001eff0 ffffffff ffffffff ffffffff ffffffff ................
001f000 ffffffff ffffffff ffffffff ffffffff ................
001f010 ffffffff ffffffff ffffffff ffffffff ................
001f020 ffffffff ffffffff ffffffff ffffffff ................
001f030 ffffffff ffffffff ffffffff ffffffff ................
001f040 ffffffff ffffffff ffffffff ffffffff ................
001f050 ffffffff ffffffff ffffffff ffffffff ................
001f060 ffffffff ffffffff ffffffff ffffffff ................
001f070 ffffffff ffffffff ffffffff ffffffff ................
001f080 ffffffff ffffffff ffffffff ffffffff ................
001f090 ffffffff ffffffff ffffffff ffffffff ................
001f0a0 ffffffff ffffffff ffffffff ffffffff ................
001f0b0 ffffffff ffffffff ffffffff ffffffff ................
001f0c0 ffffffff ffffffff ffffffff ffffffff ................
001f0d0 ffffffff ffffffff ffffffff ffffffff ................
001f0e0 ffffffff ffffffff ffffffff ffffffff ................
001f0f0 ffffffff ffffffff ffffffff ffffffff ................
001f100 ffffffff ffffffff ffffffff ffffffff ................
001f110 ffffffff ffffffff ffffffff ffffffff ................
001f120 ffffffff ffffffff ffffffff ffffffff ................
001f130 ffffffff ffffffff ffffffff ffffffff ................
001f140 ffffffff ffffffff ffffffff ffffffff ................
001f150 ffffffff ffffffff ffffffff ffffffff ................
001f160 ffffffff ffffffff ffffffff ffffffff ................
001f170 ffffffff ffffffff ffffffff ffffffff ................
001f180 ffffffff ffffffff ffffffff ffffffff ................
001f190 ffffffff ffffffff ffffffff ffffffff ................
001f1a0 ffffffff ffffffff ffffffff ffffffff ................
001f1b0 ffffffff ffffffff ffffffff ffffffff ................
001f1c0 ffffffff ffffffff ffffffff ffffffff ................
001f1d0 ffffffff ffffffff ffffffff ffffffff ................
001f1e0 ffffffff ffffffff ffffffff ffffffff ................
001f1f0 ffffffff ffffffff ffffffff ffffffff ................
001f200 ffffffff ffffffff ffffffff ffffffff ................
001f210 ffffffff ffffffff ffffffff ffffffff ................
001f220 ffffffff ffffffff ffffffff ffffffff ................
001f230 ffffffff ffffffff ffffffff ffffffff ................
001f240 ffffffff ffffffff ffffffff ffffffff ................
001f250 ffffffff ffffffff ffffffff ffffffff ................
001f260 ffffffff ffffffff ffffffff ffffffff ................
001f270 ffffffff ffffffff ffffffff ffffffff ................
001f280 ffffffff ffffffff ffffffff ffffffff ................
001f290 ffffffff ffffffff ffffffff ffffffff ................
001f2a0 ffffffff ffffffff ffffffff ffffffff ................
001f2b0 ffffffff ffffffff ffffffff ffffffff ................
001f2c0 ffffffff ffffffff ffffffff ffffffff ................
001f2d0 ffffffff ffffffff ffffffff ffffffff ................
001f2e0 ffffffff ffffffff ffffffff ffffffff ................
001f2f0 ffffffff ffffffff ffffffff ffffffff ................
001f300 ffffffff ffffffff ffffffff ffffffff ................
001f310 ffffffff ffffffff ffffffff ffffffff ................
001f320 ffffffff ffffffff ffffffff ffffffff ................
001f330 ffffffff ffffffff ffffffff ffffffff ................
001f340 ffffffff ffffffff ffffffff ffffffff ................
001f350 ffffffff ffffffff ffffffff ffffffff ................
001f360 ffffffff ffffffff ffffffff ffffffff ................
001f370 ffffffff ffffffff ffffffff ffffffff ................
001f380 ffffffff ffffffff ffffffff ffffffff ................
001f390 ffffffff ffffffff ffffffff ffffffff ................
001f3a0 ffffffff ffffffff ffffffff ffffffff ................
001f3b0 ffffffff ffffffff ffffffff ffffffff ................
001f3c0 ffffffff ffffffff ffffffff ffffffff ................
001f3d0 ffffffff ffffffff ffffffff ffffffff ................
001f3e0 ffffffff ffffffff ffffffff ffffffff ................
001f3f0 ffffffff ffffffff ffffffff ffffffff ................
001f400 ffffffff ffffffff ffffffff ffffffff ................
001f410 ffffffff ffffffff ffffffff ffffffff ................
001f420 ffffffff ffffffff ffffffff ffffffff ................
001f430 ffffffff ffffffff ffffffff ffffffff ................
001f440 ffffffff ffffffff ffffffff ffffffff ................
001f450 ffffffff ffffffff ffffffff ffffffff ................
001f460 ffffffff ffffffff ffffffff ffffffff ................
001f470 ffffffff ffffffff ffffffff ffffffff ................
001f480 ffffffff ffffffff ffffffff ffffffff ................
001f490 ffffffff ffffffff ffffffff ffffffff ................
001f4a0 ffffffff ffffffff ffffffff ffffffff ................
001f4b0 ffffffff ffffffff ffffffff ffffffff ................
001f4c0 ffffffff ffffffff ffffffff ffffffff ................
001f4d0 ffffffff ffffffff ffffffff ffffffff ................
001f4e0 ffffffff ffffffff ffffffff ffffffff ................
001f4f0 ffffffff ffffffff ffffffff ffffffff ................
001f500 ffffffff ffffffff ffffffff ffffffff ................
001f510 3a430000 3a430000 3a430000 50040000 :C..:C..:C..P...
这是我的相关代码
#define bsize (10000)
uint8_t write_buffer[bsize];
uint8_t read_buffer[bsize];
int main()
{
FILE *pttr;
pttr = fopen("binfile.bin", "rb");
if(!pttr)
{
printf("unable to open file");
return USP_FAILURE;
}
fseek(pttr, 0, SEEK_END);
rewind(pttr);
fread(read_buffer, sizeof(read_buffer), 1,pttr);
memcpy(write_buffer, read_buffer, sizeof(read_buffer));
int i;
for (i = 0; i < sizeof write_buffer; i++)
{
printf("%02x ", write_buffer[i] & 0xFF);
}
//printf("\n\n");
fclose(pttr);
return 1;
}
我的二进制文件和 objdump 的输出要大得多,额外的数据沿着 .data 部分的其余部分重复。此外,我的 printf 的输出与 obdump 命令的输出相同,因此我没有包含它。我会很感激任何建议。
附加数据实际上存在于原始文件中。查看 hexdump 中的这些行:
000000c0 ff ff ff ff 00 00 00 00 ff ff ff ff 00 00 00 00 |................|
*
000008b0 ff ff ff ff 00 00 00 00 ff ff ff ff ff ff ff ff |................|
您会注意到文件偏移量的第一列有一个很大的跳跃。仅包含 *
的行表示重复前一行直到下一行的偏移量。
如果您使用 -v
选项再次 运行 hexdump,它将打印所有输入行,您应该会看到它与您的输出匹配。