knurling-rs / flip-link

Adds zero-cost stack overflow protection to your embedded programs
Apache License 2.0
270 stars 6 forks source link

Support rust lld @file command line arguments #95

Closed great-houk closed 1 month ago

great-houk commented 2 months ago

I don't know exactly why this is a thing, but when the arguments passed to rust lld are too long (?) it gets passed a special argument (at the bottom of this page) that refers to a file. Currently, flip-link doesn't seem to handle this.

I've made a fork that "fixes" the bug by just hardcoding support and using a bunch of unwraps here, but I imagine someone who knows how linkers work and can make a good solution should be the one to make the PR.

jonathanpallant commented 1 month ago

It's because operating systems place a fairly small upper bound on the length of a command line. I think it's 8191 bytes on Windows. We should handle this, I agree.

Urhengulas commented 1 month ago

@great-houk The documentation does not state that the argument can only be in last position. From reading the docs I'd assume it can be in any. Unless it is specified somewhere else we should support it in any position.

Also can there only be one of those arguments or also multiple?

Can you open a PR with your changes? I think you can get rid of some unwraps by using if let and the like.

Btw, if you click on a heading you can link to it directly: https://doc.rust-lang.org/rustc/command-line-arguments.html#path-load-command-line-flags-from-a-path