1 // ehdr_start_test.cc -- test for __ehdr_start linker-defined symbol.
3 // Copyright (C) 2014 Free Software Foundation, Inc.
4 // Written by Cary Coutant <ccoutant@google.com>.
6 // This file is part of gold.
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.
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.
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.
23 // The goal of this program is to produce as many different types of
24 // relocations as we can in a stand-alone program that does not use
25 // TLS. This program is compiled without optimization.
34 #ifdef EHDR_START_WEAK
35 #define WEAK_ATTR __attribute__ ((weak))
40 extern char __ehdr_start[] WEAK_ATTR;
44 printf("&__ehdr_start = %p\n", &__ehdr_start);
46 #ifdef EHDR_START_UNDEF
47 assert(&__ehdr_start == 0);
49 assert(&__ehdr_start != NULL);
51 printf("ELF header: \\x%02x%c%c%c\n", __ehdr_start[0], __ehdr_start[1],
52 __ehdr_start[2], __ehdr_start[3]);
53 #ifdef EHDR_START_USER_DEF
54 assert(__ehdr_start[0] == 'a'
55 && __ehdr_start[1] == 'b'
56 && __ehdr_start[2] == 'c'
57 && __ehdr_start[3] == 'd');
59 assert(__ehdr_start[elfcpp::EI_MAG0] == elfcpp::ELFMAG0
60 && __ehdr_start[elfcpp::EI_MAG1] == elfcpp::ELFMAG1
61 && __ehdr_start[elfcpp::EI_MAG2] == elfcpp::ELFMAG2
62 && __ehdr_start[elfcpp::EI_MAG3] == elfcpp::ELFMAG3);