On 12/21/2016 10:23 AM, Torsten Duwe wrote:
diff --git a/gcc/doc/extend.texi b/gcc/doc/extend.texi
index 1f303bc..a09851a 100644
--- a/gcc/doc/extend.texi
+++ b/gcc/doc/extend.texi
@@ -3076,6 +3076,17 @@ that affect more than one function.
This attribute should be used for debugging purposes only. It is not
suitable in production code.
+@item prolog_pad
+@cindex @code{prolog_pad} function attribute
+@cindex function entry padded with NOPs
+In case the target's text segment can be made writable at run time
+by any means, padding the function entry with a number of NOPs can
+be used to provide a universal tool for instrumentation. Usually,
+prolog padding is enabled globally using the -fprolog-pad= command
+line switch, and disabled by the attribute keyword for functions
@option{-fprolog-pad=} command-line switch
+that are part of the actual instrumentation framework, to easily avoid
+an endless recursion.
I'm confused. Does the prolog_pad attribute *disable* the padding,
then? You should say that explicitly.
@item pure
@cindex @code{pure} function attribute
@cindex functions that have no side effects
diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi
index b729964..21e5067 100644
--- a/gcc/doc/invoke.texi
+++ b/gcc/doc/invoke.texi
@@ -11309,6 +11309,21 @@ of the function name, it is considered to be a match.
For C99 and C++
extended identifiers, the function name must be given in UTF-8, not
using universal character names.
+@item -fprolog-pad=N
@var{N}
+@opindex fprolog-pad
+Generate a pad of N nops right at the beginning
@var{N} again.
Can we be consistent about whether it's "NOP" or "nop"? You used "NOP"
in the doc snippet above, and that seems to be the preferred usage.
+of each function, which can be used to patch in any desired
What if the target supports NOPs of different sizes? (E.g., nios2 with
-march=r2 -mcdx).
Where, exactly, is the padding inserted? "At the beginning of each
function" might correspond to the address of the first instruction of
the function, or it might correspond to the address of some instruction
after the prolog where GDB would set a breakpoint on function entry.
This feature isn't usable without more explicit documentation about what
it does.
+instrumentation at run time, provided that the code segment
+is writeable. For run time identification, the starting addresses
s/writeable/writable/
s/run time identification/run-time identification/
+of these pads, which correspond to their respective functions,
+are additionally collected in the @code{__prolog_pads_loc} section
+of the resulting binary.
+
+Note that value of @code{__attribute__ ((prolog_pad (N)))} takes
You didn't explain this syntax in the documentation of the attribute
above...
+precedence over command-line option -fprolog_pad=N. This can be used
@option and @var markup on the option, please. And if N here is
different than N above, don't re-use the same metasyntactic variable for it.
+to increase the pad size or to remove the pad completely on a single
+function.
+
@end table
diff --git a/gcc/doc/tm.texi b/gcc/doc/tm.texi
index cdf5f48..65c265c 100644
--- a/gcc/doc/tm.texi
+++ b/gcc/doc/tm.texi
@@ -4564,6 +4564,10 @@ will select the smallest suitable mode.
This section describes the macros that output function entry
(@dfn{prologue}) and exit (@dfn{epilogue}) code.
+@deftypefn {Target Hook} void TARGET_ASM_PRINT_PROLOG_PAD (FILE *@var{file},
unsigned HOST_WIDE_INT @var{pad_size}, bool @var{record_p})
+Generate prologue pad
Needs more extensive documentation, and sentences should end in a period.
-Sandra