1 /* Copyright (C) 2002-2012 Red Hat, Inc.
2 This file is part of elfutils.
3 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
5 This file is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 3 of the License, or
8 (at your option) any later version.
10 elfutils is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>. */
22 #include ELFUTILS_HEADER(asm)
32 static const char fname[] = "asm-tst6-out.o";
42 elf_version (EV_CURRENT);
44 Ebl *ebl = ebl_openbackend_machine (EM_386);
47 puts ("cannot open backend library");
51 ctx = asm_begin (fname, ebl, false);
54 printf ("cannot create assembler context: %s\n", asm_errmsg (-1));
58 for (cnt = 0; cnt < 22000; ++cnt)
65 snprintf (buf, sizeof (buf), ".grp%Zu", cnt);
66 grp = asm_newscngrp (ctx, buf, NULL, 0);
69 printf ("cannot section group %Zu: %s\n", cnt, asm_errmsg (-1));
74 scn = asm_newscn_ingrp (ctx, ".data", SHT_PROGBITS,
75 SHF_ALLOC | SHF_WRITE, grp);
78 printf ("cannot data section for group %Zu: %s\n",
79 cnt, asm_errmsg (-1));
85 snprintf (buf, sizeof (buf), "%Zu", cnt);
86 sym = asm_newsym (scn, buf, sizeof (uint32_t), STT_OBJECT,
90 printf ("cannot create symbol \"%s\": %s\n", buf, asm_errmsg (-1));
95 /* Add some content. */
96 if (asm_adduint32 (scn, cnt) != 0)
98 printf ("cannot create content of section \"%s\": %s\n",
99 buf, asm_errmsg (-1));
104 /* Now we have a symbol, use it as the signature. */
105 if (asm_scngrp_newsignature (grp, sym) != 0)
107 printf ("cannot set signature for section group %Zu: %s\n",
108 cnt, asm_errmsg (-1));
113 /* Create a phony debug info section. */
114 scn = asm_newscn_ingrp (ctx, ".stab", SHT_PROGBITS, 0, grp);
117 printf ("cannot stab section for group %Zu: %s\n",
118 cnt, asm_errmsg (-1));
123 /* Add some content. */
124 if (asm_adduint32 (scn, cnt) != 0)
126 printf ("cannot create content of section \"%s\": %s\n",
127 buf, asm_errmsg (-1));
133 /* Create the output file. */
134 if (asm_end (ctx) != 0)
136 printf ("cannot create output file: %s\n", asm_errmsg (-1));
142 result = WEXITSTATUS (system ("../src/elflint -q asm-tst6-out.o"));
144 /* We don't need the file anymore. */
147 ebl_closebackend (ebl);