Home | History | Annotate | Download | only in testsuite
      1 /* large.c -- a test case for gold
      2 
      3    Copyright (C) 2009-2016 Free Software Foundation, Inc.
      4    Written by Ian Lance Taylor <iant (at) 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 #include <assert.h>
     24 
     25 /* Test large sections in gold.  */
     26 
     27 int v1;
     28 int v2 = 1;
     29 int v3[0x10000];
     30 int v4[0x10000] = { 1 };
     31 const int v5[0x10000] = { 2 };
     32 int v6;
     33 int v7 = 1;
     34 
     35 int
     36 main (int argc __attribute__ ((unused)), char** argv __attribute ((unused)))
     37 {
     38   assert (v1 == 0);
     39   assert (v2 == 1);
     40   assert (v3[0] == 0 && v3[0xffff] == 0);
     41   assert (v4[0] == 1 && v4[0xffff] == 0);
     42   assert (v5[0] == 2 && v5[0xffff] == 0);
     43   assert (v6 == 0);
     44   assert (v7 == 1);
     45 
     46   /* The large symbols must follow the small ones.  */
     47   assert (&v1 < v3 && &v1 < v4 && &v1 < v5);
     48   assert (&v2 < v3 && &v2 < v4 && &v2 < v5);
     49   assert (&v6 < v3 && &v6 < v4 && &v6 < v5);
     50   assert (&v7 < v3 && &v7 < v4 && &v7 < v5);
     51 
     52   /* Large symbols should be BSS followed by read-only followed by
     53      read-write.  */
     54   assert (v3 < v4);
     55   assert (v3 < v5);
     56   assert (v5 < v4);
     57 
     58   return 0;
     59 }
     60