On 16/10/17 12:31, David Brown wrote:
On 13/10/17 09:06, Sebastian Huber wrote:
Hello,
I would like to update the documentation of these compiler flags and
have some questions. The -ffunction-sections and -fdata-sections
documentation is currently:
<snip>
Do these options affect the code generation?
-fdata-sections certainly can affect code generation on some targets.
Testing with this sample, using gcc 6.3 for the ARM with -O2:
int a, b, c;
void foo(void) {
a = 1;
b = 1;
c = 1;
}
Generated assembly code is:
foo():
mov r2, #1
ldr r3, .L2
str r2, [r3]
str r2, [r3, #4]
str r2, [r3, #8]
bx lr
.L2:
.word .LANCHOR0
With -fdata-section, you get:
foo():
mov r3, #1
ldr r0, .L2
ldr r1, .L2+4
ldr r2, .L2+8
str r3, [r0]
str r3, [r1]
str r3, [r2]
bx lr
.L2:
.word .LANCHOR0
.word .LANCHOR1
.word .LANCHOR2
I only realised this recently, but it can make a significant difference
on targets that don't use direct addressing modes (such as ARM). It is
maybe worth mentioning this in any changes to the gcc documentation.
I already sent a documentation patch:
https://gcc.gnu.org/ml/gcc-patches/2017-10/msg00959.html
--
Sebastian Huber, embedded brains GmbH
Address : Dornierstr. 4, D-82178 Puchheim, Germany
Phone : +49 89 189 47 41-16
Fax : +49 89 189 47 41-09
E-Mail : sebastian.hu...@embedded-brains.de
PGP : Public key available on request.
Diese Nachricht ist keine geschäftliche Mitteilung im Sinne des EHUG.