1 /* Copyright (C) 2002-2012 Red Hat, Inc.
2 This file is part of Red Hat elfutils.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
5 Red Hat elfutils is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by the
7 Free Software Foundation; version 2 of the License.
9 Red Hat elfutils is distributed in the hope that it will be useful, but
10 WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 General Public License for more details.
14 You should have received a copy of the GNU General Public License along
15 with Red Hat elfutils; if not, write to the Free Software Foundation,
16 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
18 Red Hat elfutils is an included package of the Open Invention Network.
19 An included package of the Open Invention Network is a package for which
20 Open Invention Network licensees cross-license their patents. No patent
21 license is granted, either expressly or impliedly, by designation as an
22 included package. Should you wish to participate in the Open Invention
23 Network licensing program, please visit www.openinventionnetwork.com
24 <http://www.openinventionnetwork.com>. */
30 #include ELFUTILS_HEADER(asm)
40 static const char fname[] = "asm-tst6-out.o";
50 elf_version (EV_CURRENT);
52 Ebl *ebl = ebl_openbackend_machine (EM_386);
55 puts ("cannot open backend library");
59 ctx = asm_begin (fname, ebl, false);
62 printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
66 for (cnt = 0; cnt < 22000; ++cnt)
73 snprintf (buf, sizeof (buf), ".grp%Zu", cnt);
74 grp = asm_newscngrp (ctx, buf, NULL, 0);
77 printf ("cannot section group %Zu: %s\n", cnt, asm_errmsg (-1));
82 scn = asm_newscn_ingrp (ctx, ".data", SHT_PROGBITS,
83 SHF_ALLOC | SHF_WRITE, grp);
86 printf ("cannot data section for group %Zu: %s\n",
87 cnt, asm_errmsg (-1));
93 snprintf (buf, sizeof (buf), "%Zu", cnt);
94 sym = asm_newsym (scn, buf, sizeof (uint32_t), STT_OBJECT,
98 printf ("cannot create symbol \"%s\": %s\n", buf, asm_errmsg (-1));
103 /* Add some content. */
104 if (asm_adduint32 (scn, cnt) != 0)
106 printf ("cannot create content of section \"%s\": %s\n",
107 buf, asm_errmsg (-1));
112 /* Now we have a symbol, use it as the signature. */
113 if (asm_scngrp_newsignature (grp, sym) != 0)
115 printf ("cannot set signature for section group %Zu: %s\n",
116 cnt, asm_errmsg (-1));
121 /* Create a phony debug info section. */
122 scn = asm_newscn_ingrp (ctx, ".stab", SHT_PROGBITS, 0, grp);
125 printf ("cannot stab section for group %Zu: %s\n",
126 cnt, asm_errmsg (-1));
131 /* Add some content. */
132 if (asm_adduint32 (scn, cnt) != 0)
134 printf ("cannot create content of section \"%s\": %s\n",
135 buf, asm_errmsg (-1));
141 /* Create the output file. */
142 if (asm_end (ctx) != 0)
144 printf ("cannot create output file: %s\n", asm_errmsg (-1));
150 result = WEXITSTATUS (system ("../src/elflint -q asm-tst6-out.o"));
152 /* We don't need the file anymore. */
155 ebl_closebackend (ebl);