1 /* Create new ABS symbol.
2 Copyright (C) 2002 Red Hat, Inc.
3 This file is part of elfutils.
4 Written by Ulrich Drepper <drepper@redhat.com>, 2002.
6 This file is free software; you can redistribute it and/or modify
7 it under the terms of either
9 * the GNU Lesser General Public License as published by the Free
10 Software Foundation; either version 3 of the License, or (at
11 your option) any later version
15 * the GNU General Public License as published by the Free
16 Software Foundation; either version 2 of the License, or (at
17 your option) any later version
19 or both in parallel, as here.
21 elfutils is distributed in the hope that it will be useful, but
22 WITHOUT ANY WARRANTY; without even the implied warranty of
23 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24 General Public License for more details.
26 You should have received copies of the GNU General Public License and
27 the GNU Lesser General Public License along with this program. If
28 not, see <http://www.gnu.org/licenses/>. */
43 /* Object for special COMMON section. */
44 static const AsmScn_t __libasm_abs_scn =
55 asm_newabssym (ctx, name, size, value, type, binding)
66 /* Something went wrong before. */
69 /* Common symbols are public. Therefore the user must provide a
73 __libasm_seterrno (ASM_E_INVALID);
77 rwlock_wrlock (ctx->lock);
79 result = (AsmSym_t *) malloc (sizeof (AsmSym_t));
83 result->scn = (AsmScn_t *) &__libasm_abs_scn;
86 result->binding = binding;
88 result->strent = ebl_strtabadd (ctx->symbol_strtab, name, 0);
90 /* The value of an ABS symbol must not be modified. Since there are
91 no subsection and the initial offset of the section is 0 we can
92 get the alignment recorded by storing it into the offset
94 result->offset = value;
96 if (unlikely (ctx->textp))
98 /* An absolute symbol can be defined by giving a symbol a
100 if (binding == STB_GLOBAL)
101 fprintf (ctx->out.file, "\t.globl %s\n", name);
102 else if (binding == STB_WEAK)
103 fprintf (ctx->out.file, "\t.weak %s\n", name);
105 if (type == STT_OBJECT)
106 fprintf (ctx->out.file, "\t.type %s,@object\n", name);
107 else if (type == STT_FUNC)
108 fprintf (ctx->out.file, "\t.type %s,@function\n", name);
110 fprintf (ctx->out.file, "%s = %llu\n",
111 name, (unsigned long long int) value);
114 fprintf (ctx->out.file, "\t.size %s, %llu\n",
115 name, (unsigned long long int) size);
119 /* Put the symbol in the hash table so that we can later find it. */
120 if (asm_symbol_tab_insert (&ctx->symbol_tab, elf_hash (name), result)
123 /* The symbol already exists. */
124 __libasm_seterrno (ASM_E_DUPLSYM);
128 else if (name != NULL && asm_emit_symbol_p (name))
129 /* Only count non-private symbols. */
133 rwlock_unlock (ctx->lock);