xref: /illumos-gate/usr/src/cmd/sgs/libelf/common/member.h (revision fc910014e8a32a65612105835a10995f2c13d942)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*	Copyright (c) 1988 AT&T	*/
23 /*	  All Rights Reserved  	*/
24 
25 
26 /*
27  * Copyright (c) 1995 by Sun Microsystems, Inc.
28  * All rights reserved.
29  */
30 
31 /*
32  * Member handling
33  *	Archive members have an ASCII header.  A Member structure
34  *	holds internal information.  Because the ASCII file header
35  *	may be clobbered, Member holds a private, safe copy.
36  *	The ar_name member of m_hdr points at m_name except for string
37  *	table names.  Ar_rawname in m_hdr always points at m_raw.
38  *
39  *	m_raw	The original ar_name with null termination.
40  *		E.g., "name/           "
41  *
42  *	m_name	The processed name, with '/' terminator changed to '\0'.
43  *		Unused for string table names.  E.g., "name\0           "
44  *
45  *	To improve performance of member lookup we allocate lists which
46  * 	contain MEMIDENTNO members:
47  *
48  *	ed_memlist -->   ---------------------
49  *			|       m_next        |
50  *			|       m_end         |
51  *			|       m_free        |
52  *			|---------------------|
53  *			| m_offset | m_member |
54  *			| m_offset | m_member |
55  *			|     "    |    "     |
56  *			 ---------------------
57  */
58 
59 
60 #define	ARSZ(m)		(sizeof ((struct ar_hdr *)0)->m)
61 
62 #define	MEMIDENTNO	126
63 
64 struct	Member
65 {
66 	Elf_Arhdr	m_hdr;
67 	int		m_err;
68 	long		m_slide;
69 	char		m_raw[ARSZ(ar_name)+1];
70 	char		m_name[ARSZ(ar_name)+1];
71 };
72 
73 struct	Memident
74 {
75 	char *		m_offset;
76 	struct Member *	m_member;
77 };
78 
79 struct	Memlist
80 {
81 	struct Memlist *	m_next;
82 	struct Memident *	m_end;
83 	struct Memident *	m_free;
84 };
85