This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

RE: GNU OSC (Object Size Checking)


Excellent information! Thank you Martin. I will experiment what you described. 

Yuchen Zhou
TECHNICAL LEADER.ENGINEERING
yuczhou@cisco.com

-----Original Message-----
From: Martin Sebor [mailto:msebor@gmail.com] 
Sent: Wednesday, February 7, 2018 7:28 PM
To: Yuchen Zhou (yuczhou) <yuczhou@cisco.com>; Jonathan Wakely <jwakely.gcc@gmail.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: GNU OSC (Object Size Checking)

On 02/06/2018 10:52 PM, Yuchen Zhou (yuczhou) wrote:
> Thank you Martin, Jonathan. I think I understand it now. Of cause I may have further questions in the future.
>
> By the way, is the -O2 option a must for OSC? What about other optimization levels? I did not find much details on it.

No, it works at -O1, although it may not detect as many instances of overflow as it does with more optimization, or even with LTO.

The best way to find out when it's effective it is to experiment with some test cases and compare the output (warnings, assembly, and/or GCC dumps) between -O1 and higher levels.  There may be warnings and no runtime instrumentation or (rarely) instrumentation but no warnings.  If/when you find differences between -O levels you can then look at the internal compiler dumps to figure out which optimization pass is responsible.  Compile with -fdump-tree-all and look at the files (there will be many).
The name of the pass that implements OSC is "objsz" so look for output named <source-file>.<number>t.objsz<number>.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]