public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Is there a way to distinguish binary files compiled with -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2
@ 2021-04-08  3:28 Peng Yu
  2021-04-08 22:54 ` Martin Sebor
  2021-04-12 11:58 ` Jeff Law
  0 siblings, 2 replies; 3+ messages in thread
From: Peng Yu @ 2021-04-08  3:28 UTC (permalink / raw)
  To: gcc-help

https://gcc.gnu.org/legacy-ml/gcc-patches/2004-09/msg02055.html

When I compile a .c file with -D_FORTIFY_SOURCE=1 and
-D_FORTIFY_SOURCE=2, the binary files both contain symbols like
..._chk@...

So I can not tell whether _FORTIFY_SOURCE is 1 or 2 just by whether
symbols have ..._chk@....

Is there a way to tell the difference only from the binary file?

-- 
Regards,
Peng

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is there a way to distinguish binary files compiled with -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2
  2021-04-08  3:28 Is there a way to distinguish binary files compiled with -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2 Peng Yu
@ 2021-04-08 22:54 ` Martin Sebor
  2021-04-12 11:58 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Martin Sebor @ 2021-04-08 22:54 UTC (permalink / raw)
  To: Peng Yu, gcc-help

On 4/7/21 9:28 PM, Peng Yu via Gcc-help wrote:
> https://gcc.gnu.org/legacy-ml/gcc-patches/2004-09/msg02055.html
> 
> When I compile a .c file with -D_FORTIFY_SOURCE=1 and
> -D_FORTIFY_SOURCE=2, the binary files both contain symbols like
> ..._chk@...
> 
> So I can not tell whether _FORTIFY_SOURCE is 1 or 2 just by whether
> symbols have ..._chk@....
> 
> Is there a way to tell the difference only from the binary file?
> 

_FORTIFY_SOURCE is a Glibc macro so the libc list is probably a better
source of information than this one.  I don't know of a GCC mechanism
to determine what level was used.  The macro and its definition might
be in the debug section in the .o file when compiling with -g3.

Martin

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Is there a way to distinguish binary files compiled with -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2
  2021-04-08  3:28 Is there a way to distinguish binary files compiled with -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2 Peng Yu
  2021-04-08 22:54 ` Martin Sebor
@ 2021-04-12 11:58 ` Jeff Law
  1 sibling, 0 replies; 3+ messages in thread
From: Jeff Law @ 2021-04-12 11:58 UTC (permalink / raw)
  To: Peng Yu, gcc-help


On 4/7/2021 9:28 PM, Peng Yu via Gcc-help wrote:
> https://gcc.gnu.org/legacy-ml/gcc-patches/2004-09/msg02055.html
>
> When I compile a .c file with -D_FORTIFY_SOURCE=1 and
> -D_FORTIFY_SOURCE=2, the binary files both contain symbols like
> ..._chk@...
>
> So I can not tell whether _FORTIFY_SOURCE is 1 or 2 just by whether
> symbols have ..._chk@....
>
> Is there a way to tell the difference only from the binary file?

annobin/annocheck is probably the most likely way to be able to detect 
this, but I don't know offhand if it can distinguish between the 
different fortify-source levels.  It also (naturally) assumes you've got 
the annobin plugin installed and that it was enabled when you built your 
code.


Nick Clifton (nickc@redhat.com) is probably the best contact point for 
understanding annobin/annocheck's capabilities.


jeff


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2021-04-12 11:58 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-08  3:28 Is there a way to distinguish binary files compiled with -D_FORTIFY_SOURCE=1 and -D_FORTIFY_SOURCE=2 Peng Yu
2021-04-08 22:54 ` Martin Sebor
2021-04-12 11:58 ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).