Merge branch 'master' of ssh://crater.dragonflybsd.org/repository/git/dragonfly
[dragonfly.git] / gnu / usr.bin / cc34 / doc / patches / invoke.texi.patch
blob615846f01049690222f27da4da568997a6669147
1 $DragonFly: src/gnu/usr.bin/cc34/doc/patches/invoke.texi.patch,v 1.2 2005/08/27 21:03:52 joerg Exp $
3 Index: invoke.texi
4 ===================================================================
5 RCS file: /home/joerg/wd/repository/dragonflybsd/src/contrib/gcc-3.4/gcc/doc/invoke.texi,v
6 retrieving revision 1.4
7 diff -u -r1.4 invoke.texi
8 --- invoke.texi 10 Aug 2005 15:50:46 -0000 1.4
9 +++ invoke.texi 27 Aug 2005 16:44:10 -0000
10 @@ -183,7 +183,8 @@
11 -fno-optional-diags -fpermissive @gol
12 -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol
13 -fuse-cxa-atexit -fno-weak -nostdinc++ @gol
14 --fno-default-inline -Wabi -Wctor-dtor-privacy @gol
15 +-fno-default-inline -fvisibility-inlines-hidden @gol
16 +-Wabi -Wctor-dtor-privacy @gol
17 -Wnon-virtual-dtor -Wreorder @gol
18 -Weffc++ -Wno-deprecated @gol
19 -Wno-non-template-friend -Wold-style-cast @gol
20 @@ -227,7 +228,7 @@
21 -Wno-multichar -Wnonnull -Wpacked -Wpadded @gol
22 -Wparentheses -Wpointer-arith -Wredundant-decls @gol
23 -Wreturn-type -Wsequence-point -Wshadow @gol
24 --Wsign-compare -Wstrict-aliasing @gol
25 +-Wsign-compare -Wstack-protector -Wstrict-aliasing @gol
26 -Wswitch -Wswitch-default -Wswitch-enum @gol
27 -Wsystem-headers -Wtrigraphs -Wundef -Wuninitialized @gol
28 -Wunknown-pragmas -Wunreachable-code @gol
29 @@ -675,10 +676,12 @@
30 -fshort-double -fshort-wchar @gol
31 -fverbose-asm -fpack-struct -fstack-check @gol
32 -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol
33 +-fstack-protector -fstack-protector-all @gol
34 -fargument-alias -fargument-noalias @gol
35 -fargument-noalias-global -fleading-underscore @gol
36 -ftls-model=@var{model} @gol
37 --ftrapv -fwrapv -fbounds-check}
38 +-ftrapv -fwrapv -fbounds-check @gol
39 +-fvisibility}
40 @end table
42 @menu
43 @@ -1437,6 +1440,20 @@
44 destructors, but will only work if your C library supports
45 @code{__cxa_atexit}.
47 +@item -fvisibility-inlines-hidden
48 +@opindex fvisibility-inlines-hidden
49 +Causes all inlined methods to be marked with
50 +@code{__attribute__ ((visibility ("hidden")))} so that they do not
51 +appear in the export table of a DSO and do not require a PLT indirection
52 +when used within the DSO. Enabling this option can have a dramatic effect
53 +on load and link times of a DSO as it massively reduces the size of the
54 +dynamic export table when the library makes heavy use of templates. While
55 +it can cause bloating through duplication of code within each DSO where
56 +it is used, often the wastage is less than the considerable space occupied
57 +by a long symbol name in the export table which is typical when using
58 +templates and namespaces. For even more savings, combine with the
59 +@code{-fvisibility=hidden} switch.
61 @item -fno-weak
62 @opindex fno-weak
63 Do not use weak symbol support, even if it is provided by the linker.
64 @@ -2986,6 +3003,10 @@
65 complex; GCC will refuse to optimize programs when the optimization
66 itself is likely to take inordinate amounts of time.
68 +@item -Wstack-protector
69 +@opindex Wstack-protector
70 +Warn when not issuing stack smashing protection for some reason.
72 @item -Werror
73 @opindex Werror
74 Make all warnings into errors.
75 @@ -11232,6 +11253,24 @@
76 @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit
77 of 128KB@. Note that this may only work with the GNU linker.
79 +@item -fstack-protector
80 +@item -fstack-protector-all
81 +@opindex fstack-protector
82 +@opindex fstack-protector-all
83 +@opindex fno-stack-protector
84 +Generate code to protect an application from a stack smashing
85 +attack. The features are (1) the insertion of random value next to the
86 +frame pointer to detect the integrity of the stack, (2) the reordering
87 +of local variables to place buffers after pointers to avoid the
88 +corruption of pointers that could be used to further corrupt arbitrary
89 +memory locations, (3) the copying of pointers in function arguments to
90 +an area preceding local variable buffers to prevent the corruption of
91 +pointers that could be used to further corrupt arbitrary memory
92 +locations, and the (4) omission of instrumentation code from some
93 +functions to decrease the performance overhead. If the integrity
94 +would be broken, the program is aborted. If stack-protector-all is
95 +specified, instrumentation codes are generated at every functions.
97 @cindex aliasing of parameters
98 @cindex parameters, aliased
99 @item -fargument-alias
100 @@ -11271,6 +11310,54 @@
102 The default without @option{-fpic} is @code{initial-exec}; with
103 @option{-fpic} the default is @code{global-dynamic}.
105 +@item -fvisibility=@var{default|internal|hidden|protected}
106 +@opindex fvisibility
107 +Set the default ELF image symbol visibility to the specified option - all
108 +symbols will be marked with this unless overrided within the code.
109 +Using this feature can very substantially improve linking and
110 +load times of shared object libraries, produce more optimised
111 +code, provide near-perfect API export and prevent symbol clashes.
112 +It is @strong{strongly} recommended that you use this in any shared objects
113 +you distribute.
115 +Despite the nomenclature, @code{default} always means public ie;
116 +available to be linked against from outside the shared object.
117 +@code{protected} and @code{internal} are pretty useless in real-world
118 +usage so the only other commonly used option will be @code{hidden}.
119 +The default if -fvisibility isn't specified is @code{default} ie; make every
120 +symbol public - this causes the same behaviour as previous versions of
121 +GCC.
123 +A good explanation of the benefits offered by ensuring ELF
124 +symbols have the correct visibility is given by ``How To Write
125 +Shared Libraries'' by Ulrich Drepper (which can be found at
126 +@w{@uref{http://people.redhat.com/~drepper/}}) - however a superior
127 +solution made possible by this option to marking things hidden when
128 +the default is public is to make the default hidden and mark things
129 +public. This is the norm with DLL's on Windows and with @option{-fvisibility=hidden}
130 +and @code{__attribute__ ((visibility("default")))} instead of
131 +@code{__declspec(dllexport)} you get almost identical semantics with
132 +identical syntax. This is a great boon to those working with
133 +cross-platform projects.
135 +For those adding visibility support to existing code, you may find
136 +@samp{#pragma GCC visibility} of use. This works by you enclosing
137 +the declarations you wish to set visibility for with (for example)
138 +@samp{#pragma GCC visibility push(hidden)} and
139 +@samp{#pragma GCC visibility pop}. These can be nested up to sixteen
140 +times. Bear in mind that symbol visibility should be viewed @strong{as
141 +part of the API interface contract} and thus all new code should
142 +always specify visibility when it is not the default ie; declarations
143 +only for use within the local DSO should @strong{always} be marked explicitly
144 +as hidden as so to avoid PLT indirection overheads - making this
145 +abundantly clear also aids readability and self-documentation of the code.
146 +Note that due to ISO C++ specification requirements, operator new and
147 +operator delete must always be of default visibility.
149 +An overview of these techniques, their benefits and how to use them
150 +is at @w{@uref{http://www.nedprod.com/programs/gccvisibility.html}}.
152 @end table
154 @c man end