cbindgen
cbindgen copied to clipboard
Add a way to generate a list of symbols for dynamic linkage
This resolves #907 by adding the ability to generate the list of exportable symbols (i.e. functions and globals), in a format that the linker (ld) can understand. Like depfile
, this new feature is available both as a CLI option (--symfile
) and as a method in Bindings
. Therefore, it's easy to use it in a build script.
Most of the new files are tests on the output of the new option --symfile
.
Which linkers specifically support this option? Is the
--dynamic-list
option of the gold linker compatible with the format, or did you only test withldd
? Is there any documentation on the exact format?
The manual doesn't clearly explain the format. Gnu linker's manual reads "The format of the dynamic list is the same as the version node without scope and node name. See VERSION", and that "version" thing is introduced here.
I would expect at least GNU ld, lld and gold to work with that (I have only tested ld for the moment, but I'm confident that it works with lld too since it's been implemented with the same format in 2016). It would be weird for a linker to offer the same option but with a different format IMO.
rebased