[cfe-users] App security and the __FILE__ macro
Rick Mann via cfe-users
cfe-users at lists.llvm.org
Fri Apr 13 23:53:43 PDT 2018
> On Apr 13, 2018, at 23:52 , Steffen Hirschmann <steffen.hirschmann at ipvs.uni-stuttgart.de> wrote:
>
> On 13:22 Fri 13 Apr , Rick Mann via cfe-users wrote:
>> I'm using `strrchr("/" __FILE__, '/') + 1`. Should that also get resolved?
> Just have a look at a minimal example on godbolt:
> https://godbolt.org/g/MRjGG3
>
> Indeed the function call gets resolved at compile time. But that does
> not mean that only the basename of __FILE__ is present in the binary.
> No compiler that you can test on godbolt does this actually, neither
> with -O3 nor with -Os.
And it's worse than that. We have a lot of third-party code that uses __FILE__ directly without trimming it. The best solution really would be a command-line option to modify the behavior of __FILE__. I hope the patch makes it in. I'm going to recommend a similar one for Swift.
--
Rick Mann
rmann at latencyzero.com
More information about the cfe-users
mailing list