https://gcc.gnu.org/bugzilla/show_bug.cgi?id=77422
H.J. Lu <hjl.tools at gmail dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Summary|-fdata-sections should put |-fdata-sections should put
|each string literal in its |each constant in its own
|own section |section
--- Comment #1 from H.J. Lu <hjl.tools at gmail dot com> ---
Constant has the same issue:
[hjl@gnu-6 string-1]$ cat y.i
void
foo (void)
{
__builtin_printf ("%f\n", 20000.1);
__builtin_printf ("%f\n", 20000.2);
}
int
main ()
{
__builtin_printf ("%f\n", 20000.2);
__builtin_printf ("%f\n", 20000.3);
return 0;
}
[hjl@gnu-6 string-1]$ make y.s
/export/build/gnu/gcc/build-x86_64-linux/gcc/xgcc
-B/export/build/gnu/gcc/build-x86_64-linux/gcc/ -O2 -fdata-sections
-ffunction-sections -S -o y.s y.i
[hjl@gnu-6 string-1]$ cat y.s
.file "y.i"
.section .rodata.foo.str1.1,"aMS",@progbits,1
.LC1:
.string "%f\n"
.section .text.foo,"ax",@progbits
.p2align 4,,15
.globl foo
.type foo, @function
foo:
.LFB0:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $.LC1, %edi
movl $1, %eax
movsd .LC0(%rip), %xmm0
call printf
movsd .LC2(%rip), %xmm0
movl $.LC1, %edi
movl $1, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
jmp printf
.cfi_endproc
.LFE0:
.size foo, .-foo
.section .text.startup.main,"ax",@progbits
.p2align 4,,15
.globl main
.type main, @function
main:
.LFB1:
.cfi_startproc
subq $8, %rsp
.cfi_def_cfa_offset 16
movl $.LC1, %edi
movl $1, %eax
movsd .LC2(%rip), %xmm0
call printf
movsd .LC3(%rip), %xmm0
movl $.LC1, %edi
movl $1, %eax
call printf
xorl %eax, %eax
addq $8, %rsp
.cfi_def_cfa_offset 8
ret
.cfi_endproc
.LFE1:
.size main, .-main
.section .rodata.cst8,"aM",@progbits,8
.align 8
.LC0:
.long 1717986918
.long 1087604742
.align 8
.LC2:
.long 3435973837
.long 1087604748
.align 8
.LC3:
.long 858993459
.long 1087604755
.ident "GCC: (GNU) 7.0.0 20160829 (experimental)"
.section .note.GNU-stack,"",@progbits
[hjl@gnu-6 string-1]$