11844Swollman// defstd.cc -- define standard symbols for gold. 250476Speter 31844Swollman// Copyright (C) 2006-2020 Free Software Foundation, Inc. 41638Srgrimes// Written by Ian Lance Taylor <iant@google.com>. 594940Sru 61638Srgrimes// This file is part of gold. 7281056Sbdrewery 8281056Sbdrewery// This program is free software; you can redistribute it and/or modify 9281056Sbdrewery// it under the terms of the GNU General Public License as published by 10281056Sbdrewery// the Free Software Foundation; either version 3 of the License, or 11281056Sbdrewery// (at your option) any later version. 12281056Sbdrewery 13281056Sbdrewery// This program is distributed in the hope that it will be useful, 1442915Sjdp// but WITHOUT ANY WARRANTY; without even the implied warranty of 1542915Sjdp// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1642915Sjdp// GNU General Public License for more details. 1742915Sjdp 18139106Sru// You should have received a copy of the GNU General Public License 1942915Sjdp// along with this program; if not, write to the Free Software 2042915Sjdp// Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, 2142915Sjdp// MA 02110-1301, USA. 22129024Sdes 23129024Sdes#include "gold.h" 2429141Speter 25129024Sdes#include "symtab.h" 26129024Sdes#include "layout.h" 27129024Sdes#include "defstd.h" 28125119Sru 29100332Sru// This is a simple file which defines the standard symbols like 30100332Sru// "_end". 3142915Sjdp 3242915Sjdpnamespace 3329141Speter{ 34119607Sru 35117034Sgordonusing namespace gold; 36119607Sru 37117034Sgordonconst Define_symbol_in_section in_section[] = 38162210Simp{ 39162210Simp { 40162293Sobrien "__preinit_array_start", // name 41162210Simp ".preinit_array", // output_section 42162210Simp 0, // value 432827Sjkh 0, // size 442827Sjkh elfcpp::STT_NOTYPE, // type 45179184Sjb elfcpp::STB_GLOBAL, // binding 46228158Sfjoe elfcpp::STV_HIDDEN, // visibility 47179184Sjb 0, // nonvis 482827Sjkh false, // offset_is_from_end 49244224Semaste true // only_if_ref 501638Srgrimes }, 512827Sjkh { 521638Srgrimes "__preinit_array_end", // name 53251512Semaste ".preinit_array", // output_section 54251512Semaste 0, // value 55251512Semaste 0, // size 56251512Semaste elfcpp::STT_NOTYPE, // type 57251512Semaste elfcpp::STB_GLOBAL, // binding 58251512Semaste elfcpp::STV_HIDDEN, // visibility 5918529Sbde 0, // nonvis 6018529Sbde true, // offset_is_from_end 611638Srgrimes true // only_if_ref 6242450Sjdp }, 631638Srgrimes { 64220755Sdim "__init_array_start", // name 651638Srgrimes ".init_array", // output_section 6696512Sru 0, // value 67211725Simp 0, // size 6896512Sru elfcpp::STT_NOTYPE, // type 6996512Sru elfcpp::STB_GLOBAL, // binding 7096512Sru elfcpp::STV_HIDDEN, // visibility 7196512Sru 0, // nonvis 7296512Sru false, // offset_is_from_end 7396512Sru true // only_if_ref 74126890Strhodes }, 75126890Strhodes { 76227797Sdes "__init_array_end", // name 77227797Sdes ".init_array", // output_section 78228137Sfjoe 0, // value 79227797Sdes 0, // size 801638Srgrimes elfcpp::STT_NOTYPE, // type 81227797Sdes elfcpp::STB_GLOBAL, // binding 82228137Sfjoe elfcpp::STV_HIDDEN, // visibility 831638Srgrimes 0, // nonvis 8442450Sjdp true, // offset_is_from_end 85227797Sdes true // only_if_ref 86228137Sfjoe }, 871844Swollman { 88236810Sdim "__fini_array_start", // name 89227797Sdes ".fini_array", // output_section 90227797Sdes 0, // value 9136673Sdt 0, // size 92227797Sdes elfcpp::STT_NOTYPE, // type 931844Swollman elfcpp::STB_GLOBAL, // binding 9442450Sjdp elfcpp::STV_HIDDEN, // visibility 95227797Sdes 0, // nonvis 961844Swollman false, // offset_is_from_end 971844Swollman true // only_if_ref 98127027Strhodes }, 99228137Sfjoe { 1001844Swollman "__fini_array_end", // name 10142450Sjdp ".fini_array", // output_section 1021844Swollman 0, // value 103228137Sfjoe 0, // size 1041844Swollman elfcpp::STT_NOTYPE, // type 105117173Sru elfcpp::STB_GLOBAL, // binding 106117159Sru elfcpp::STV_HIDDEN, // visibility 107228137Sfjoe 0, // nonvis 1081638Srgrimes true, // offset_is_from_end 109117173Sru true // only_if_ref 110217100Skib }, 111217100Skib { 112228137Sfjoe "__stack", // name 113117173Sru ".stack", // output_section 114117173Sru 0, // value 115217100Skib 0, // size 116117173Sru elfcpp::STT_NOTYPE, // type 117228137Sfjoe elfcpp::STB_GLOBAL, // binding 118117173Sru elfcpp::STV_DEFAULT, // visibility 1191844Swollman 0, // nonvis 120217100Skib false, // offset_is_from_end 121228137Sfjoe true // only_if_ref 1221844Swollman }, 12342450Sjdp}; 124217100Skib 125228137Sfjoeconst int in_section_count = sizeof in_section / sizeof in_section[0]; 1261844Swollman 127269946Srpauloconst Define_symbol_in_segment in_segment[] = 128269946Srpaulo{ 1291638Srgrimes { 130255384Sdes "__executable_start", // name 131255384Sdes elfcpp::PT_LOAD, // segment_type 132255384Sdes elfcpp::PF(0), // segment_flags_set 133255384Sdes elfcpp::PF(0), // segment_flags_clear 134255384Sdes 0, // value 135255384Sdes 0, // size 136255384Sdes elfcpp::STT_NOTYPE, // type 137255384Sdes elfcpp::STB_GLOBAL, // binding 138247054Semaste elfcpp::STV_DEFAULT, // visibility 139251512Semaste 0, // nonvis 140251512Semaste Symbol::SEGMENT_START, // offset_from_base 141251512Semaste true // only_if_ref 142255384Sdes }, 143251512Semaste { 144251512Semaste "__ehdr_start", // name 145255384Sdes elfcpp::PT_LOAD, // segment_type 146247054Semaste elfcpp::PF(0), // segment_flags_set 147255384Sdes elfcpp::PF(0), // segment_flags_clear 148251512Semaste 0, // value 149251512Semaste 0, // size 150251512Semaste elfcpp::STT_NOTYPE, // type 151247054Semaste elfcpp::STB_GLOBAL, // binding 152247054Semaste elfcpp::STV_HIDDEN, // visibility 153247054Semaste 0, // nonvis 154247054Semaste Symbol::SEGMENT_START, // offset_from_base 155168317Skan true // only_if_ref 156156772Sdeischen }, 157178047Skan { 158168317Skan "etext", // name 159169822Sru elfcpp::PT_LOAD, // segment_type 160247054Semaste elfcpp::PF_X, // segment_flags_set 161156772Sdeischen elfcpp::PF_W, // segment_flags_clear 162156772Sdeischen 0, // value 163156772Sdeischen 0, // size 164255384Sdes elfcpp::STT_NOTYPE, // type 165255384Sdes elfcpp::STB_GLOBAL, // binding 166255384Sdes elfcpp::STV_DEFAULT, // visibility 167255384Sdes 0, // nonvis 16899362Sru Symbol::SEGMENT_END, // offset_from_base 16999362Sru true // only_if_ref 17099362Sru }, 17199362Sru { 17296512Sru "_etext", // name 17396512Sru elfcpp::PT_LOAD, // segment_type 1741638Srgrimes elfcpp::PF_X, // segment_flags_set 17596512Sru elfcpp::PF_W, // segment_flags_clear 17696512Sru 0, // value 17796512Sru 0, // size 178243933Seadler elfcpp::STT_NOTYPE, // type 179270484Sdes elfcpp::STB_GLOBAL, // binding 18099362Sru elfcpp::STV_DEFAULT, // visibility 1811638Srgrimes 0, // nonvis 18296512Sru Symbol::SEGMENT_END, // offset_from_base 18395114Sobrien true // only_if_ref 184156854Sru }, 18596512Sru { 18696512Sru "__etext", // name 18795306Sru elfcpp::PT_LOAD, // segment_type 18896512Sru elfcpp::PF_X, // segment_flags_set 18996512Sru elfcpp::PF_W, // segment_flags_clear 19096512Sru 0, // value 191243933Seadler 0, // size 192270484Sdes elfcpp::STT_NOTYPE, // type 19374805Sru elfcpp::STB_GLOBAL, // binding 1941844Swollman elfcpp::STV_DEFAULT, // visibility 19599362Sru 0, // nonvis 19699362Sru Symbol::SEGMENT_END, // offset_from_base 19796512Sru true // only_if_ref 19899362Sru }, 1991844Swollman { 20096512Sru "_edata", // name 20196512Sru elfcpp::PT_LOAD, // segment_type 2021638Srgrimes elfcpp::PF_W, // segment_flags_set 203228307Skib elfcpp::PF(0), // segment_flags_clear 204228307Skib 0, // value 205228307Skib 0, // size 206228307Skib elfcpp::STT_NOTYPE, // type 207228307Skib elfcpp::STB_GLOBAL, // binding 208212423Srpaulo elfcpp::STV_DEFAULT, // visibility 209244915Smarkj 0, // nonvis 210244915Smarkj Symbol::SEGMENT_BSS, // offset_from_base 211244224Semaste false // only_if_ref 212244915Smarkj }, 21342915Sjdp { 214244236Semaste "edata", // name 21542915Sjdp elfcpp::PT_LOAD, // segment_type 216245752Sbrooks elfcpp::PF_W, // segment_flags_set 21742915Sjdp elfcpp::PF(0), // segment_flags_clear 218281056Sbdrewery 0, // value 21996512Sru 0, // size 220163683Sru elfcpp::STT_NOTYPE, // type 221228158Sfjoe elfcpp::STB_GLOBAL, // binding 222228124Sfjoe elfcpp::STV_DEFAULT, // visibility 223163683Sru 0, // nonvis 224244236Semaste Symbol::SEGMENT_BSS, // offset_from_base 225251512Semaste true // only_if_ref 226251512Semaste }, 227251512Semaste { 228251512Semaste "__bss_start", // name 229244915Smarkj elfcpp::PT_LOAD, // segment_type 230244236Semaste elfcpp::PF_W, // segment_flags_set 231251512Semaste elfcpp::PF(0), // segment_flags_clear 232244915Smarkj 0, // value 233228124Sfjoe 0, // size 234248806Smarkj elfcpp::STT_NOTYPE, // type 2351844Swollman elfcpp::STB_GLOBAL, // binding 236156813Sru elfcpp::STV_DEFAULT, // visibility 23796512Sru 0, // nonvis 23896512Sru Symbol::SEGMENT_BSS, // offset_from_base 23996512Sru false // only_if_ref 2402353Sbde }, 24196512Sru { 242243933Seadler "_end", // name 243270484Sdes elfcpp::PT_LOAD, // segment_type 2443859Sbde elfcpp::PF_W, // segment_flags_set 2451844Swollman elfcpp::PF(0), // segment_flags_clear 246139106Sru 0, // value 24796512Sru 0, // size 24896512Sru elfcpp::STT_NOTYPE, // type 24996512Sru elfcpp::STB_GLOBAL, // binding 25096512Sru elfcpp::STV_DEFAULT, // visibility 25192491Smarkm 0, // nonvis 25296512Sru Symbol::SEGMENT_END, // offset_from_base 25396512Sru false // only_if_ref 25492491Smarkm }, 25592491Smarkm { 2561638Srgrimes "end", // name 257144893Sharti elfcpp::PT_LOAD, // segment_type 25896512Sru elfcpp::PF_W, // segment_flags_set 25996512Sru elfcpp::PF(0), // segment_flags_clear 26096512Sru 0, // value 261156813Sru 0, // size 26296512Sru elfcpp::STT_NOTYPE, // type 2631638Srgrimes elfcpp::STB_GLOBAL, // binding 2641638Srgrimes elfcpp::STV_DEFAULT, // visibility 26534179Sbde 0, // nonvis 26624750Sbde Symbol::SEGMENT_END, // offset_from_base 26742450Sjdp true // only_if_ref 26824750Sbde } 26924750Sbde}; 270139107Sru 27131809Sbdeconst int in_segment_count = sizeof in_segment / sizeof in_segment[0]; 272279958Sjhb 27327910Sasami} // End anonymous namespace. 27428945Speter 2751638Srgrimesnamespace gold 2761638Srgrimes{ 2771638Srgrimes 278136019Sruvoid 279139111Srudefine_standard_symbols(Symbol_table* symtab, const Layout* layout) 2802298Swollman{ 2812298Swollman bool saw_sections_clause = layout->script_options()->saw_sections_clause(); 282136019Sru symtab->define_symbols(layout, in_section_count, in_section, 283136019Sru saw_sections_clause); 2842298Swollman symtab->define_symbols(layout, in_segment_count, in_segment, 28549328Shoek saw_sections_clause); 28649328Shoek} 28749328Shoek 28849328Shoek} // End namespace gold. 28956971Sru