4 ms·
On the other hand, it appears to have a great bang/buck. Link existing programs against the hardened libc++ and get those checks for "free" (other than the perf
by yazzku 4y ago
On the other hand, it appears to have a great bang/buck. Link existing programs against the hardened libc++ and get those checks for "free" (other than the perf hit.)
- jeffbee 4y agoI'm not at all clear on how exactly that would work. The entire program would have to be rebuilt from scratch, would it not? Things like std::vector::operator[] are not runtime library calls, they are almost always inlined by the compiler. You could not simply take an existing program, replace its runtime library, and get bounds-checked vector accesses.
- pjmlp 4y agoDepends how the linking took place, and optimization levels.
- planede 4y agovector is a template, at most vector<some_type>::operator[] will be a weak symbol, and I bet it's inlined from -O1 and above.
- gpderetta 4y agoEven if not inlined at -O0, when instantiated for a custom some_type, the standard library .so won't contain any code for it, everything will be in the application binary.
- pjmlp 4y agoDepends on the implementation of helper functions and if external templates are being used.
- pjmlp 4y agoOn Windows it can still live on a dynamic library. That has been a thing since the Windows 16 bit days, and other OSes with similar linking models like Symbian, OS/2 and AIX.
- jeffbee 4y agoIt’s difficult to imagine which applications would find the performance of an outline vector access acceptable. Generally vector::operator[] is represented in built programs by a single x86 mov. A call would wreck the performance. In languages with bounds-checked vectors, they don’t do it with library calls.
- pjmlp 4y agoI have practically always used bounds checked vectors and strings. In the old days, all C++ frameworks bundled with compilers tended to have bounds checking enabled by default (Turbo Vision, OWL, VCL, MFC, PowerPlant, CSet++, Qt,...). Nowadays I always set _ITERATOR_DEBUG_LEVEL to 1 on VC++, unless I am not allowed to. Mostly the performance problems that were dealt with, had to do with badly chosen algorithms and data structures. Modern Android ships with FORTIFY enabled. https://android-developers.googleblog.com/2017/04/fortify-in-android.html https://android-developers.googleblog.com/2017/04/fortify-in...
- gpderetta 4y agoOf course, it is a compiler feature, you will have to recompile and manually (or automatically) apply all suggested changes to the source code. If you just link against an hardened library, only the implementation of the (non inlined) library calls will be hardened, the user code itself won't see much benefits. Of course these days we have binary level optimizers, so who knows what it is possible in principle?
- yazzku 4y agoSorry, I used 'link' very liberally there, but you cleared it up. My point was that (from what I remember, it's been a few days) you'd mostly just need to recompile. As opposed to, you know, Rewrite It In Rust (TM).