blob: ab1be0c6301c2408487b96005682e6e47020bed2 [file] [log] [blame]
Ulrich Drepperce0bdb62007-02-05 07:13:52 +00001/* Copyright (C) 2007 Red Hat, Inc.
2 Written by Ulrich Drepper <drepper@redhat.com>, 2007.
3
4 Red Hat elfutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by the
6 Free Software Foundation; version 2 of the License.
7
8 Red Hat elfutils is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with Red Hat elfutils; if not, write to the Free Software Foundation,
15 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
16
17 Red Hat elfutils is an included package of the Open Invention Network.
18 An included package of the Open Invention Network is a package for which
19 Open Invention Network licensees cross-license their patents. No patent
20 license is granted, either expressly or impliedly, by designation as an
21 included package. Should you wish to participate in the Open Invention
22 Network licensing program, please visit www.openinventionnetwork.com
23 <http://www.openinventionnetwork.com>. */
24
25#ifndef _ARLIB_H
26#define _ARLIB_H 1
27
28#include <ar.h>
29#include <byteswap.h>
30#include <endian.h>
31#include <libelf.h>
32#include <obstack.h>
33#include <stddef.h>
34#include <stdint.h>
35#include <sys/types.h>
36
37
38/* Maximum length of a file name that fits directly into the ar header. */
39#define MAX_AR_NAME_LEN (sizeof (((struct ar_hdr *) NULL)->ar_name))
40
41
42/* Words matching in size to archive header. */
43#define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t))
44
45
46#if __BYTE_ORDER == __LITTLE_ENDIAN
47# define le_bswap_32(val) bswap_32 (val)
48#else
49# define le_bswap_32(val) (val)
50#endif
51
52
53/* Symbol table type. */
54struct arlib_symtab
55{
56 /* Symbol table handling. */
57 struct obstack symsoffob;
58 struct obstack symsnameob;
59 size_t symsofflen;
60 uint32_t *symsoff;
61 size_t symsnamelen;
62 char *symsname;
63
64 /* Long filename handling. */
65 struct obstack longnamesob;
66 size_t longnameslen;
67 char *longnames;
68};
69
70
71/* Initialize ARLIB_SYMTAB structure. */
72extern void arlib_init (struct arlib_symtab *symtab);
73
74
75/* Finalize ARLIB_SYMTAB content. */
76extern void arlib_finalize (struct arlib_symtab *symtab);
77
78/* Free resources for ARLIB_SYMTAB. */
79extern void arlib_fini (struct arlib_symtab *symtab);
80
81/* Add symbols from ELF with value OFFSET to the symbol table SYMTAB. */
82extern void arlib_add_symbols (Elf *elf, const char *arfname,
83 const char *membername,
84 struct arlib_symtab *symtab, off_t off);
85
86/* Add name a file offset of a symbol. */
87extern void arlib_add_symref (struct arlib_symtab *symtab, const char *symname,
88 off_t symoff);
89
90/* Add long file name FILENAME of length FILENAMELEN to the symbol table
91 SYMTAB. Return the offset into the long file name table. */
92extern long int arlib_add_long_name (struct arlib_symtab *symtab,
93 const char *filename, size_t filenamelen);
94
95#endif /* arlib.h */