chen3feng / blade-build

Blade is a powerful build system from Tencent, supports many mainstream programming languages, such as C/C++, java, scala, python, protobuf...
Other
2.04k stars 501 forks source link

Reimplement resource_library using objcopy #817

Open chen3feng opened 3 years ago

chen3feng commented 3 years ago
$ objcopy -I binary -O elf32-little flare/rpc/protocol/http/builtin/resources/static/jquery-1.11.2.min.js data.o
$ nm data.o
000176bb D _binary_flare_rpc_protocol_http_builtin_resources_static_jquery_1_11_2_min_js_end
000176bb A _binary_flare_rpc_protocol_http_builtin_resources_static_jquery_1_11_2_min_js_size
00000000 D _binary_flare_rpc_protocol_http_builtin_resources_static_jquery_1_11_2_min_js_start

maybe faster.

chen3feng commented 3 years ago

Something like this would be a starting point:

objcopy --input binary \
    --output elf64-x86-64 \
    --binary-architecture i386:x86-64 \
    myfile.txt myfile.o

If you wanted to generate 32-bit objects you could use:

objcopy --input binary \
    --output elf32-i386 \
    --binary-architecture i386 \
    myfile.txt myfile.o

https://stackoverflow.com/questions/42235175/how-do-i-add-contents-of-text-file-as-a-section-in-an-elf-file

chen3feng commented 3 years ago

https://stackoverflow.com/questions/4158900/embedding-resources-in-executable-using-gcc

ld -r -b binary
$ ld -r -b binary -o outfile.o /bin/ls
$ nm outfile.o
0000000000023008 D _binary__bin_ls_end
0000000000023008 A _binary__bin_ls_size
0000000000000000 D _binary__bin_ls_star