blob: fd26d248843c584b5b9610393d4ac8990a96f782 [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
Ulrich Drepperb597dfa2007-10-16 05:21:27 +000038/* Maximum length of a file name that fits directly into the ar header.
39 We cannot use the final byte since a / goes there. */
40#define MAX_AR_NAME_LEN (sizeof (((struct ar_hdr *) NULL)->ar_name) - 1)
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000041
42
43/* Words matching in size to archive header. */
44#define AR_HDR_WORDS (sizeof (struct ar_hdr) / sizeof (uint32_t))
45
46
47#if __BYTE_ORDER == __LITTLE_ENDIAN
48# define le_bswap_32(val) bswap_32 (val)
49#else
50# define le_bswap_32(val) (val)
51#endif
52
53
54/* Symbol table type. */
55struct arlib_symtab
56{
57 /* Symbol table handling. */
58 struct obstack symsoffob;
59 struct obstack symsnameob;
60 size_t symsofflen;
61 uint32_t *symsoff;
62 size_t symsnamelen;
63 char *symsname;
64
65 /* Long filename handling. */
66 struct obstack longnamesob;
67 size_t longnameslen;
68 char *longnames;
69};
70
71
Ulrich Drepper0fe63532007-02-05 21:05:51 +000072/* Global variable with symbol table. */
73extern struct arlib_symtab symtab;
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000074
75
Ulrich Drepper0fe63532007-02-05 21:05:51 +000076/* Initialize ARLIB_SYMTAB structure. */
77extern void arlib_init (void);
78
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000079/* Finalize ARLIB_SYMTAB content. */
Ulrich Drepper0fe63532007-02-05 21:05:51 +000080extern void arlib_finalize (void);
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000081
82/* Free resources for ARLIB_SYMTAB. */
Ulrich Drepper0fe63532007-02-05 21:05:51 +000083extern void arlib_fini (void);
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000084
85/* Add symbols from ELF with value OFFSET to the symbol table SYMTAB. */
86extern void arlib_add_symbols (Elf *elf, const char *arfname,
Ulrich Drepper0fe63532007-02-05 21:05:51 +000087 const char *membername, off_t off);
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000088
89/* Add name a file offset of a symbol. */
Ulrich Drepper0fe63532007-02-05 21:05:51 +000090extern void arlib_add_symref (const char *symname, off_t symoff);
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000091
92/* Add long file name FILENAME of length FILENAMELEN to the symbol table
93 SYMTAB. Return the offset into the long file name table. */
Ulrich Drepper0fe63532007-02-05 21:05:51 +000094extern long int arlib_add_long_name (const char *filename, size_t filenamelen);
Ulrich Drepperce0bdb62007-02-05 07:13:52 +000095
96#endif /* arlib.h */