Update year range in copyright notice of binutils files
[binutils-gdb.git] / binutils / testsuite / binutils-all / pr25662.s
1 /* PR 25662: objcopy sets invalid sh_offset for the first section in a
2 no_contents segment containing program headers.
3
4 Several conditions are required for the bug to manifest:
5 - The first loadable segment (which contains the program headers) must only
6 contain SHT_NOBITS sections. .bss is the SHT_NOBITS section in this test.
7 - The next loadable segment must have a !SHT_NOBITS loadable section. .data
8 is the !SHT_NOBITS section in this test.
9 - .bss must be positioned after .data in the executable file itself.
10 - The size of .data must be such that the calculated VMA of the .bss
11 section that follows it is not congruent with the file offset of .bss,
12 modulo the p_align of its segment, i.e.:
13 (VMA(.data) + sizeof(.data)) % (.bss_segment.p_align) != 0
14 This will force the sh_offset of .bss to be aligned so it appears within
15 .data.
16 - The size of .data must be larger than the program headers in the first
17 loadable segment, so that the file offset of .bss is immediately
18 after .data, and not padded to a valid alignment by the program headers.
19
20 The bug originally only manifested for ELF targets, but there's no reason not
21 to run this testcase for other file formats. */
22
23 .section .bss
24 aaa:
25 .zero 0x2
26
27 .section .data
28 ccc:
29 .zero 0x201
30
31 .section .text
32 .global _start
33 _start:
34 .long 0