-B bfdarch
--binary-architecture=bfdarch
Useful when transforming a architecture-less input file into an object file. In this case the output architecture can be set to bfdarch. This
option will be ignored if the input file has a known bfdarch. You can access this binary data inside a program by referencing the special
symbols that are created by the conversion process. These symbols are called _binary_objfile_start, _binary_objfile_end and
_binary_objfile_size. e.g. you can transform a picture file into an object file and then access it in your code using these symbols.
_binary_my_data_txt_start: 5
_binary_my_data_txt_end:
Program received signal SIGSEGV, Segmentation fault.
main (argc=1, argv=0x7fffffffe1d8) at test_obj.c:24
24 printf("_binary_my_data_txt_size: %d\n", _binary_my_data_txt_size);
(gdb) p _binary_my_data_txt_size
Cannot access memory at address 0x7
疑?變數位址是0x7?那我把測試檔案內容改一下,增加3個字元,再跑一次gdb。
my_data.txt
1
8HelloABC
gdb 結果
12
(gdb) p _binary_my_data_txt_size
Cannot access memory at address 0xa