3 ms·
This is broken: .incbin "string_blob.txt" ... printf("%s\n", string_blob); Text files don't have to have a NUL termination. The proper way to embed dat
by kevin_thibedeau 4y ago
This is broken:
.incbin "string_blob.txt"
...
printf("%s\n", string_blob);
Text files don't have to have a NUL termination. The proper way to embed data with the .incbin directive is to add a label after the file and use that directly for pointer arithmetic or compute the size with another assembly directive.
- kelnos 4y agoIn this case it works because the author explicitly put a NUL at the end of the string in the text file. I don't think the author was trying to suggest that you can do this with arbitrary data.
- jandrese 4y agoCouldn't you follow up the .incbin statement with a .const 0 or something similar?