blob: f06252d71f00edf91500cea9e571396b31fb5988 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Internal interfaces for libelf.
Ulrich Drepperc07fbb32007-03-30 19:14:59 +00002 Copyright (C) 1998,1999,2000,2001,2002,2003,2005,2006,2007 Red Hat, Inc.
Ulrich Drepper361df7d2006-04-04 21:38:57 +00003 This file is part of Red Hat elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00004 Contributed by Ulrich Drepper <drepper@redhat.com>, 1998.
5
Ulrich Drepper361df7d2006-04-04 21:38:57 +00006 Red Hat elfutils is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by the
8 Free Software Foundation; version 2 of the License.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00009
Ulrich Drepper361df7d2006-04-04 21:38:57 +000010 Red Hat 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 GNU
13 General Public License for more details.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000014
Ulrich Drepper361df7d2006-04-04 21:38:57 +000015 You should have received a copy of the GNU General Public License along
16 with Red Hat elfutils; if not, write to the Free Software Foundation,
Ulrich Drepper1e9ef502006-04-04 22:29:06 +000017 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000018
19 In addition, as a special exception, Red Hat, Inc. gives You the
20 additional right to link the code of Red Hat elfutils with code licensed
21 under any Open Source Initiative certified open source license
22 (http://www.opensource.org/licenses/index.php) which requires the
23 distribution of source code with any binary distribution and to
24 distribute linked combinations of the two. Non-GPL Code permitted under
25 this exception must only link to the code of Red Hat elfutils through
26 those well defined interfaces identified in the file named EXCEPTION
27 found in the source code files (the "Approved Interfaces"). The files
28 of Non-GPL Code may instantiate templates or use macros or inline
29 functions from the Approved Interfaces without causing the resulting
30 work to be covered by the GNU General Public License. Only Red Hat,
31 Inc. may make changes or additions to the list of Approved Interfaces.
32 Red Hat's grant of this exception is conditioned upon your not adding
33 any new exceptions. If you wish to add a new Approved Interface or
34 exception, please contact Red Hat. You must obey the GNU General Public
35 License in all respects for all of the Red Hat elfutils code and other
36 code used in conjunction with Red Hat elfutils except the Non-GPL Code
37 covered by this exception. If you modify this file, you may extend this
38 exception to your version of the file, but you are not obligated to do
39 so. If you do not wish to provide this exception without modification,
40 you must delete this exception statement from your version and license
41 this file solely under the GPL without exception.
42
43 Red Hat elfutils is an included package of the Open Invention Network.
44 An included package of the Open Invention Network is a package for which
45 Open Invention Network licensees cross-license their patents. No patent
46 license is granted, either expressly or impliedly, by designation as an
47 included package. Should you wish to participate in the Open Invention
48 Network licensing program, please visit www.openinventionnetwork.com
49 <http://www.openinventionnetwork.com>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000050
51#ifndef _LIBELFP_H
52#define _LIBELFP_H 1
53
54#include <ar.h>
55#include <gelf.h>
56#include <stdint.h>
57
58/* gettext helper macros. */
59#define _(Str) dgettext ("libelf", Str)
60
61
62/* Helper Macros to write 32 bit and 64 bit functions. */
63#define __elfw2_(Bits, Name) __elf##Bits##_##Name
64#define elfw2_(Bits, Name) elf##Bits##_##Name
65#define ElfW2_(Bits, Name) Elf##Bits##_##Name
66#define ELFW2_(Bits, Name) ELF##Bits##_##Name
67#define ELFW_(Name, Bits) Name##Bits
68#define __elfw2(Bits, Name) __elfw2_(Bits, Name)
69#define elfw2(Bits, Name) elfw2_(Bits, Name)
70#define ElfW2(Bits, Name) ElfW2_(Bits, Name)
71#define ELFW2(Bits, Name) ELFW2_(Bits, Name)
72#define ELFW(Name, Bits) ELFW_(Name, Bits)
73
74
75/* Sizes of the external types, for 32 bits objects. */
76#define ELF32_FSZ_ADDR 4
77#define ELF32_FSZ_OFF 4
78#define ELF32_FSZ_HALF 2
79#define ELF32_FSZ_WORD 4
80#define ELF32_FSZ_SWORD 4
81#define ELF32_FSZ_XWORD 8
82#define ELF32_FSZ_SXWORD 8
83
84/* Same for 64 bits objects. */
85#define ELF64_FSZ_ADDR 8
86#define ELF64_FSZ_OFF 8
87#define ELF64_FSZ_HALF 2
88#define ELF64_FSZ_WORD 4
89#define ELF64_FSZ_SWORD 4
90#define ELF64_FSZ_XWORD 8
91#define ELF64_FSZ_SXWORD 8
92
93
94/* This is an extension of the ELF_F_* enumeration. The values here are
95 not part of the library interface, they are only used internally. */
96enum
97{
98 ELF_F_MMAPPED = 0x40,
99 ELF_F_MALLOCED = 0x80,
100 ELF_F_FILEDATA = 0x100
101};
102
103
104/* Get definition of all the external types. */
105#include "exttypes.h"
106
107
108/* Error values. */
109enum
110{
111 ELF_E_NOERROR = 0,
112 ELF_E_UNKNOWN_ERROR,
113 ELF_E_UNKNOWN_VERSION,
114 ELF_E_UNKNOWN_TYPE,
115 ELF_E_INVALID_HANDLE,
116 ELF_E_SOURCE_SIZE,
117 ELF_E_DEST_SIZE,
118 ELF_E_INVALID_ENCODING,
119 ELF_E_NOMEM,
120 ELF_E_INVALID_FILE,
121 ELF_E_INVALID_OP,
122 ELF_E_NO_VERSION,
123 ELF_E_INVALID_CMD,
124 ELF_E_RANGE,
125 ELF_E_ARCHIVE_FMAG,
126 ELF_E_INVALID_ARCHIVE,
127 ELF_E_NO_ARCHIVE,
128 ELF_E_NO_INDEX,
129 ELF_E_READ_ERROR,
130 ELF_E_WRITE_ERROR,
131 ELF_E_INVALID_CLASS,
132 ELF_E_INVALID_INDEX,
133 ELF_E_INVALID_OPERAND,
134 ELF_E_INVALID_SECTION,
135 ELF_E_INVALID_COMMAND,
136 ELF_E_WRONG_ORDER_EHDR,
137 ELF_E_FD_DISABLED,
138 ELF_E_FD_MISMATCH,
139 ELF_E_OFFSET_RANGE,
140 ELF_E_NOT_NUL_SECTION,
141 ELF_E_DATA_MISMATCH,
142 ELF_E_INVALID_SECTION_HEADER,
143 ELF_E_INVALID_DATA,
144 ELF_E_DATA_ENCODING,
145 ELF_E_SECTION_TOO_SMALL,
146 ELF_E_INVALID_ALIGN,
147 ELF_E_INVALID_SHENTSIZE,
148 ELF_E_UPDATE_RO,
149 ELF_E_NOFILE,
150 ELF_E_GROUP_NOT_REL,
151 ELF_E_INVALID_PHDR,
152 ELF_E_NO_PHDR,
Ulrich Drepper41de4882005-08-03 00:02:56 +0000153 ELF_E_INVALID_OFFSET,
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000154 /* Keep this as the last entry. */
155 ELF_E_NUM
156};
157
158
159/* The visible `Elf_Data' type is not sufficent for some operations due
160 to a misdesigned interface. Extend it for internal purposes. */
161typedef struct
162{
163 Elf_Data d;
164 Elf_Scn *s;
165} Elf_Data_Scn;
166
167
168/* List of `Elf_Data' descriptors. This is what makes up the section
169 contents. */
170typedef struct Elf_Data_List
171{
172 /* `data' *must* be the first element in the struct. */
173 Elf_Data_Scn data;
174 struct Elf_Data_List *next;
175 int flags;
176} Elf_Data_List;
177
178
179/* Descriptor for ELF section. */
180struct Elf_Scn
181{
182 /* We have to distinguish several different situations:
183
184 1. the section is user created. Therefore there is no file or memory
185 region to read the data from. Here we have two different subcases:
186
187 a) data was not yet added (before the first `elf_newdata' call)
188
189 b) at least one data set is available
190
191 2. this is a section from a file/memory region. We have to read the
192 current content in one data block if we have to. But we don't
193 read the data until it is necessary. So we have the subcases:
194
195 a) the section in the file has size zero (for whatever reason)
196
197 b) the data of the file is not (yet) read
198
199 c) the data is read and available.
200
201 In addition to this we have different data sets, the raw and the converted
202 data. This distinction only exists for the data read from the file.
203 All user-added data set (all but the first when read from the file or
204 all of them for user-create sections) are the same in both formats.
205 We don't create the converted data before it is necessary.
206
207 The `data_read' element signals whether data is available in the
208 raw format.
209
210 If there is data from the file/memory region or if read one data
211 set is added the `rawdata_list_read' pointer in non-NULL and points
212 to the last filled data set. `raw_datalist_rear' is therefore NULL
213 only if there is no data set at all.
214
215 This so far allows to distinguish all but two cases (given that the
216 `rawdata_list' and `data_list' entries are initialized to zero) is
217 between not yet loaded data from the file/memory region and a section
218 with zero size and type ELF_T_BYTE. */
219 Elf_Data_List data_list; /* List of data buffers. */
220 Elf_Data_List *data_list_rear; /* Pointer to the rear of the data list. */
221
222 Elf_Data_Scn rawdata; /* Uninterpreted data of the section. */
223
224 int data_read; /* Nonzero if the section was created by the
225 user or if the data from the file/memory
226 is read. */
227
228 size_t index; /* Index of this section. */
229 struct Elf *elf; /* The underlying ELF file. */
230
231 union
232 {
233 Elf32_Shdr *e32; /* Pointer to 32bit section header. */
234 Elf64_Shdr *e64; /* Pointer to 64bit section header. */
235 } shdr;
236
237 unsigned int shdr_flags; /* Section header modified? */
238 unsigned int flags; /* Section changed in size? */
239
240 char *rawdata_base; /* The unmodified data of the section. */
241 char *data_base; /* The converted data of the section. */
242
243 struct Elf_ScnList *list; /* Pointer the the section list element the
244 data is in. */
245};
246
247
248/* List of section. */
249typedef struct Elf_ScnList
250{
251 unsigned int cnt; /* Number of elements of 'data' used. */
252 unsigned int max; /* Number of elements of 'data' allocated. */
253 struct Elf_ScnList *next; /* Next block of sections. */
254 struct Elf_Scn data[0]; /* Section data. */
255} Elf_ScnList;
256
257
258/* The ELF descriptor. */
259struct Elf
260{
261 /* What kind of file is underneath (ELF file, archive...). */
262 Elf_Kind kind;
263
264 /* Command used to create this descriptor. */
265 Elf_Cmd cmd;
266
267 /* The binary class. */
268 unsigned int class;
269
270 /* The used file descriptor. -1 if not available anymore. */
271 int fildes;
272
273 /* Offset in the archive this file starts or zero. */
274 off_t start_offset;
275
276 /* Size of the file in the archive or the entire file size, or ~0
277 for an (yet) unknown size. */
278 size_t maximum_size;
279
280 /* Address to which the file was mapped. NULL if not mapped. */
281 void *map_address;
282
283 /* Describes the way the memory was allocated and if the dirty bit is
284 signalled it means that the whole file has to be rewritten since
285 the layout changed. */
286 int flags;
287
288 /* When created for an archive member this points to the descriptor
289 for the archive. */
290 Elf *parent;
291
292 /* Lock to handle multithreaded programs. */
293 rwlock_define (,lock);
294
295 /* Reference counting for the descriptor. */
296 int ref_count;
297
298 struct Elf *next; /* Used in list of archive descriptors. */
299
300 union
301 {
302 struct
303 {
304 int ehdr_flags; /* Flags (dirty) for ELF header. */
305 int phdr_flags; /* Flags (dirty|malloc) for program header. */
306 int shdr_malloced; /* Nonzero if shdr array was allocated. */
307
308 /* The next fields are only useful when testing for ==/!= NULL. */
309 void *ehdr;
310 void *shdr;
311 void *phdr;
312
313 Elf_ScnList *scns_last; /* Last element in the section list.
314 If NULL the data has not yet been
315 read from the file. */
316 unsigned int scnincr; /* Number of sections allocate the last
317 time. */
318 off64_t sizestr_offset; /* Offset of the size string in the parent
319 if this is an archive member. */
320 } elf;
321
322 struct
323 {
324 int ehdr_flags; /* Flags (dirty) for ELF header. */
325 int phdr_flags; /* Flags (dirty|malloc) for program header. */
326 int shdr_malloced; /* Nonzero if shdr array was allocated. */
327
328 Elf32_Ehdr *ehdr; /* Pointer to the ELF header. This is
329 never malloced. */
330 Elf32_Shdr *shdr; /* Used when reading from a file. */
331 Elf32_Phdr *phdr; /* Pointer to the program header array. */
332 Elf_ScnList *scns_last; /* Last element in the section list.
333 If NULL the data has not yet been
334 read from the file. */
335 unsigned int scnincr; /* Number of sections allocate the last
336 time. */
337 off64_t sizestr_offset; /* Offset of the size string in the parent
338 if this is an archive member. */
339 Elf32_Ehdr ehdr_mem; /* Memory used for ELF header when not
340 mmaped. */
341 char __e32scnspad[sizeof (Elf64_Ehdr) - sizeof (Elf32_Ehdr)];
342
343 /* The section array. */
344 Elf_ScnList scns;
345 } elf32;
346
347 struct
348 {
349 int ehdr_flags; /* Flags (dirty) for ELF header. */
350 int phdr_flags; /* Flags (dirty|malloc) for program header. */
351 int shdr_malloced; /* Nonzero if shdr array was allocated. */
352
353 Elf64_Ehdr *ehdr; /* Pointer to the ELF header. This is
354 never malloced. */
355 Elf64_Shdr *shdr; /* Used when reading from a file. */
356 Elf64_Phdr *phdr; /* Pointer to the program header array. */
357 Elf_ScnList *scns_last; /* Last element in the section list.
358 If NULL the data has not yet been
359 read from the file. */
360 unsigned int scnincr; /* Number of sections allocate the last
361 time. */
362 off64_t sizestr_offset; /* Offset of the size string in the parent
363 if this is an archive member. */
364 Elf64_Ehdr ehdr_mem; /* Memory used for ELF header when not
365 mmaped. */
366
367 /* The section array. */
368 Elf_ScnList scns;
369 } elf64;
370
371 struct
372 {
373 int has_index; /* Set when file has index. 0 means
374 undecided, > 0 means it has one. */
375 Elf_Arsym *ar_sym; /* Symbol table returned by elf_getarsym. */
376 size_t ar_sym_num; /* Number of entries in `ar_sym'. */
377 char *long_names; /* If no index is available but long names
378 are used this elements points to the data.*/
379 size_t long_names_len; /* Length of the long name table. */
380 off_t offset; /* Offset in file we are currently at.
381 elf_next() advances this to the next
382 member of the archive. */
383 Elf_Arhdr elf_ar_hdr; /* Structure returned by 'elf_getarhdr'. */
384 struct ar_hdr ar_hdr; /* Header read from file. */
385 char ar_name[16]; /* NUL terminated ar_name of elf_ar_hdr. */
386 char raw_name[17]; /* This is a buffer for the NUL terminated
387 named raw_name used in the elf_ar_hdr. */
388 struct Elf *children; /* List of all descriptors for this archive. */
389 } ar;
390 } state;
391
392 /* There absolutely never must be anything following the union. */
393};
394
395
396/* Type of the conversion functions. These functions will convert the
397 byte order. */
398typedef void (*xfct_t) (void *, const void *, size_t, int);
399
400/* The table with the function pointers. */
401extern const xfct_t __elf_xfctstom[EV_NUM - 1][EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden;
402extern const xfct_t __elf_xfctstof[EV_NUM - 1][EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden;
403
404
405/* Array with sizes of the external types indexed by ELF version, binary
406 class, and type. */
407extern const size_t __libelf_type_sizes[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden;
408/* We often have to access the size for a type in the current version. */
409#if EV_NUM != 2
410# define elf_typesize(class,type,n) \
411 elfw2(class,fsize) (type, n, __libelf_version)
412#else
413# define elf_typesize(class,type,n) \
414 (__libelf_type_sizes[EV_CURRENT - 1][ELFW(ELFCLASS,class) - 1][type] * n)
415#endif
416
417/* Currently selected version of the ELF specification. */
418extern unsigned int __libelf_version attribute_hidden;
419
420/* The byte value used for filling gaps. */
421extern int __libelf_fill_byte attribute_hidden;
422
423/* Nonzero if the version was set. */
424extern int __libelf_version_initialized attribute_hidden;
425
Ulrich Drepperc07fbb32007-03-30 19:14:59 +0000426/* Index for __libelf_type_sizes et al. */
427#if EV_NUM == 2
428# define LIBELF_EV_IDX 0
429#else
430# define LIBELF_EV_IDX (__libelf_version - 1)
431#endif
432
433#if !ALLOW_UNALIGNED
434/* Array with alignment requirements of the internal types indexed by ELF
435 version, binary class, and type. */
436extern const uint_fast8_t __libelf_type_aligns[EV_NUM - 1][ELFCLASSNUM - 1][ELF_T_NUM] attribute_hidden;
437# define __libelf_type_align(class, type) \
438 (__libelf_type_aligns[LIBELF_EV_IDX][class][type] ?: 1)
439#else
440# define __libelf_type_align(class, type) 1
441#endif
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000442
443/* The libelf API does not have such a function but it is still useful.
444 Get the memory size for the given type.
445
446 These functions cannot be marked internal since they are aliases
447 of the export elfXX_fsize functions.*/
448extern size_t __elf32_msize (Elf_Type __type, size_t __count,
449 unsigned int __version);
450extern size_t __elf64_msize (Elf_Type __type, size_t __count,
451 unsigned int __version);
452
453
454/* Create Elf descriptor from memory image. */
455extern Elf *__libelf_read_mmaped_file (int fildes, void *map_address,
456 off_t offset, size_t maxsize,
457 Elf_Cmd cmd, Elf *parent)
458 internal_function;
459
460/* Set error value. */
461extern void __libelf_seterrno (int value) internal_function;
462
463/* Get the next archive header. */
464extern int __libelf_next_arhdr (Elf *elf) internal_function;
465
466/* Read all of the file associated with the descriptor. */
467extern char *__libelf_readall (Elf *elf) internal_function;
468
469/* Read the complete section table and convert the byte order if necessary. */
470extern int __libelf_readsections (Elf *elf) internal_function;
471
472/* Store the information for the raw data in the `rawdata_list' element. */
473extern int __libelf_set_rawdata (Elf_Scn *scn) internal_function;
474
475
476/* Helper functions for elf_update. */
477extern off_t __elf32_updatenull (Elf *elf, int *change_bop, size_t shnum)
478 internal_function;
479extern off_t __elf64_updatenull (Elf *elf, int *change_bop, size_t shnum)
480 internal_function;
481
482extern int __elf32_updatemmap (Elf *elf, int change_bo, size_t shnum)
483 internal_function;
484extern int __elf64_updatemmap (Elf *elf, int change_bo, size_t shnum)
485 internal_function;
486extern int __elf32_updatefile (Elf *elf, int change_bo, size_t shnum)
487 internal_function;
488extern int __elf64_updatefile (Elf *elf, int change_bo, size_t shnum)
489 internal_function;
490
491
492/* Alias for exported functions to avoid PLT entries. */
493extern int __elf_end_internal (Elf *__elf);
494extern Elf *__elf_begin_internal (int __fildes, Elf_Cmd __cmd, Elf *__ref)
495 attribute_hidden;
496extern Elf32_Ehdr *__elf32_getehdr_internal (Elf *__elf) attribute_hidden;
497extern Elf64_Ehdr *__elf64_getehdr_internal (Elf *__elf) attribute_hidden;
498extern Elf32_Ehdr *__elf32_newehdr_internal (Elf *__elf) attribute_hidden;
499extern Elf64_Ehdr *__elf64_newehdr_internal (Elf *__elf) attribute_hidden;
500extern Elf32_Phdr *__elf32_getphdr_internal (Elf *__elf) attribute_hidden;
501extern Elf64_Phdr *__elf64_getphdr_internal (Elf *__elf) attribute_hidden;
502extern Elf32_Phdr *__elf32_newphdr_internal (Elf *__elf, size_t __cnt)
503 attribute_hidden;
504extern Elf64_Phdr *__elf64_newphdr_internal (Elf *__elf, size_t __cnt)
505 attribute_hidden;
Ulrich Drepper41de4882005-08-03 00:02:56 +0000506extern Elf_Scn *__elf32_offscn_internal (Elf *__elf, Elf32_Off __offset)
507 attribute_hidden;
508extern Elf_Scn *__elf64_offscn_internal (Elf *__elf, Elf64_Off __offset)
509 attribute_hidden;
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000510extern int __elf_getshnum_internal (Elf *__elf, size_t *__dst)
511 attribute_hidden;
512extern int __elf_getshstrndx_internal (Elf *__elf, size_t *__dst)
513 attribute_hidden;
514extern Elf32_Shdr *__elf32_getshdr_internal (Elf_Scn *__scn) attribute_hidden;
515extern Elf64_Shdr *__elf64_getshdr_internal (Elf_Scn *__scn) attribute_hidden;
516extern Elf_Scn *__elf_getscn_internal (Elf *__elf, size_t __index)
517 attribute_hidden;
518extern Elf_Scn *__elf_nextscn_internal (Elf *__elf, Elf_Scn *__scn)
519 attribute_hidden;
520extern Elf_Data *__elf_getdata_internal (Elf_Scn *__scn, Elf_Data *__data)
521 attribute_hidden;
522extern Elf_Data *__elf_rawdata_internal (Elf_Scn *__scn, Elf_Data *__data)
523 attribute_hidden;
524extern char *__elf_strptr_internal (Elf *__elf, size_t __index,
525 size_t __offset) attribute_hidden;
526extern Elf_Data *__elf32_xlatetom_internal (Elf_Data *__dest,
527 const Elf_Data *__src,
528 unsigned int __encode)
529 attribute_hidden;
530extern Elf_Data *__elf64_xlatetom_internal (Elf_Data *__dest,
531 const Elf_Data *__src,
532 unsigned int __encode)
533 attribute_hidden;
534extern Elf_Data *__elf32_xlatetof_internal (Elf_Data *__dest,
535 const Elf_Data *__src,
536 unsigned int __encode)
537 attribute_hidden;
538extern Elf_Data *__elf64_xlatetof_internal (Elf_Data *__dest,
539 const Elf_Data *__src,
540 unsigned int __encode)
541 attribute_hidden;
542extern unsigned int __elf_version_internal (unsigned int __version)
543 attribute_hidden;
544extern unsigned long int __elf_hash_internal (const char *__string)
545 __attribute__ ((__pure__, visibility ("hidden")));
546extern long int __elf32_checksum_internal (Elf *__elf) attribute_hidden;
547extern long int __elf64_checksum_internal (Elf *__elf) attribute_hidden;
548
549
550extern GElf_Ehdr *__gelf_getehdr_internal (Elf *__elf, GElf_Ehdr *__dest);
551extern size_t __gelf_fsize_internal (Elf *__elf, Elf_Type __type,
552 size_t __count, unsigned int __version)
553 attribute_hidden;
554extern GElf_Shdr *__gelf_getshdr_internal (Elf_Scn *__scn, GElf_Shdr *__dst)
555 attribute_hidden;
556extern GElf_Sym *__gelf_getsym_internal (Elf_Data *__data, int __ndx,
557 GElf_Sym *__dst) attribute_hidden;
558
559
560extern uint32_t __libelf_crc32 (uint32_t crc, unsigned char *buf, size_t len)
561 attribute_hidden;
562
563
564/* We often have to update a flag iff a value changed. Make this
Ulrich Drepper697f4db2006-06-10 06:50:47 +0000565 convenient. */
566#define update_if_changed(var, exp, flag) \
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000567 do { \
568 __typeof__ (var) *_var = &(var); \
569 __typeof__ (exp) _exp = (exp); \
570 if (*_var != _exp) \
571 { \
572 *_var = _exp; \
573 (flag) |= ELF_F_DIRTY; \
574 } \
575 } while (0)
Ulrich Drepperb08d5a82005-07-26 05:00:05 +0000576
577#endif /* libelfP.h */