ChangeLog rotatation and copyright year update
[deliverable/binutils-gdb.git] / gold / testsuite / script_test_2.cc
CommitLineData
a445fddf
ILT
1// script_test_2.cc -- linker script test 2 for gold -*- C++ -*-
2
b90efa5b 3// Copyright (C) 2008-2015 Free Software Foundation, Inc.
a445fddf
ILT
4// Written by Ian Lance Taylor <iant@google.com>.
5
6// This file is part of gold.
7
8// This program is free software; you can redistribute it and/or modify
9// it under the terms of the GNU General Public License as published by
10// the Free Software Foundation; either version 3 of the License, or
11// (at your option) any later version.
12
13// This program is distributed in the hope that it will be useful,
14// but WITHOUT ANY WARRANTY; without even the implied warranty of
15// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16// GNU General Public License for more details.
17
18// You should have received a copy of the GNU General Public License
19// along with this program; if not, write to the Free Software
20// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
21// MA 02110-1301, USA.
22
23// A test of some uses of the SECTIONS clause. Look at
24// script_test_2.t to make sense of this test.
25
26#include <cassert>
27#include <cstddef>
28#include <cstring>
29#include <stdint.h>
30
31extern char start_test_area[];
32extern char start_test_area_1[];
33extern char start_data[];
34extern char end_data[];
35extern char start_fill[];
36extern char end_fill[];
37extern char end_test_area[];
7c07ecec
ILT
38extern char test_addr[];
39extern char test_addr_alias[];
a445fddf
ILT
40
41int
42main(int, char**)
43{
44 assert(reinterpret_cast<uintptr_t>(start_test_area) == 0x20000001);
45 assert(reinterpret_cast<uintptr_t>(start_test_area_1) == 0x20000010);
46
47 // We should see the string from script_test_2b.o next. The
48 // subalign should move it up to 0x20000020.
49 for (int i = 0; i < 16; ++i)
50 assert(start_test_area_1[i] == 0);
7c98e6bb 51 assert(strcmp(start_test_area_1 + 16, "test bb") == 0);
a445fddf
ILT
52
53 // Next the string from script_test_2a.o, after the subalign.
54 for (int i = 16 + 7; i < 48; ++i)
55 assert(start_test_area_1[i] == 0);
83bfb6b7 56 assert(strcmp(start_test_area_1 + 48, "test aa") == 0);
a445fddf
ILT
57
58 // Move four bytes forward to start_data.
7c98e6bb 59 assert(reinterpret_cast<uintptr_t>(start_test_area_1 + 48 + 8 + 4)
a445fddf
ILT
60 == reinterpret_cast<uintptr_t>(start_data));
61 assert(memcmp(start_data, "\1\2\0\4\0\0\0\010\0\0\0\0\0\0\0", 15) == 0
62 || memcmp(start_data, "\1\0\2\0\0\0\4\0\0\0\0\0\0\0\010", 15) == 0);
63 assert(end_data == start_data + 15);
64
65 // Check that FILL works as expected.
66 assert(start_fill == end_data);
67 assert(memcmp(start_fill, "\x12\x34\x56\x78\x12\x34\x56\0", 8) == 0);
68 assert(end_fill == start_fill + 8);
69
70 assert(end_test_area == end_fill);
7c07ecec
ILT
71
72 assert(test_addr == start_test_area_1);
73 assert(test_addr_alias == test_addr);
a445fddf 74}
This page took 0.48948 seconds and 4 git commands to generate.