3 ms·
Where did they define the symbols `_binary_quine_c_start` and `_binary_quine_c_end`? I would expect that the symbol names would need to be passed to the command
by quietbritishjim 7y ago
Where did they define the symbols `_binary_quine_c_start` and `_binary_quine_c_end`? I would expect that the symbol names would need to be passed to the command that produced the object file from the binary file:
ld -r -b binary quine.c -o myself.o -m elf_amd64
- CraneWorm 7y ago> I would expect that the symbol names would need to be passed to the command that produced the object file from the binary file: It's the other way around. The command produces these symbols basing on the file name: $ readelf --symbols myself.o Symbol table '.symtab' contains 5 entries: Num: Value Size Type Bind Vis Ndx Name 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 2: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 _binary_quine_c_start 3: 0000000000000113 0 NOTYPE GLOBAL DEFAULT ABS _binary_quine_c_size 4: 0000000000000113 0 NOTYPE GLOBAL DEFAULT 1 _binary_quine_c_end
- idoby 7y agoThose are standardized named generated by ld, derived from the file name (in this case "quine", which is treated by the author both as C source and a binary data file). I bet there's a CLI switch to change the defaults.
- tyingq 7y agoThey are assuming gnu ld, and that's the pattern it uses. It will change some characters, like "." to "_" to keep valid symbol names. GNU objcopy has a way to change the generated names. As far as I can tell, ld does not.