2 * Copyright (c) 2013 The Native Client Authors. All rights reserved.
3 * Use of this source code is governed by a BSD-style license that can be
4 * found in the LICENSE file.
7 #include "native_client/src/trusted/service_runtime/nacl_config.h"
12 * This test attempts to get both the assembler and the linker to generate
13 * all the different kinds of nop instructions they will generate when
14 * doing alignment padding in the code segment. Running the output through
15 * the validator ensures that it accepts all these nop forms.
18 .macro fill_before length
20 * Fill space at the start of a bundle leaving exactly |length|
21 * bytes before the end of the bundle.
23 .fill ((1 << NACL_BLOCK_SHIFT) - \length) / NACL_HALT_LEN, \
24 NACL_HALT_LEN, NACL_HALT_OPCODE
29 * Create the circumstance where exactly |length| bytes must be
30 * filled to perform '.p2align NACL_BLOCK_SHIFT', and then let the
31 * assembler fill it with its choice of nops.
33 .p2align NACL_BLOCK_SHIFT
34 test_as_nop_\length\():
36 .p2align NACL_BLOCK_SHIFT
40 * Now create the same circumstance in the linker when it stitches
41 * this section to the next one (which has sh_addralign=32).
43 .pushsection .text.nop.\length, "ax", %progbits
44 .p2align NACL_BLOCK_SHIFT
45 test_ld_nop_\length\():
50 #if NACL_BLOCK_SHIFT == 5 && NACL_HALT_LEN == 1
81 #elif NACL_BLOCK_SHIFT == 4 && NACL_HALT_LEN == 4
86 # error "architecture not handled by this test"
90 * This section follows .text.nop.31 and creates (by virtue of its
91 * alignment) the need for the linker to generate the last nop
94 .pushsection .text.nop.end, "ax", %progbits
95 .p2align NACL_BLOCK_SHIFT