cbindgen icon indicating copy to clipboard operation
cbindgen copied to clipboard

Add a way to generate a list of symbols for dynamic linkage

Open TheElectronWill opened this issue 5 months ago • 2 comments

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.

TheElectronWill avatar Jan 08 '24 16:01 TheElectronWill

Which linkers specifically support this option? Is the --dynamic-list option of the gold linker compatible with the format, or did you only test with ldd? 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.

TheElectronWill avatar Jan 09 '24 21:01 TheElectronWill

rebased

TheElectronWill avatar Mar 12 '24 13:03 TheElectronWill