1 /* simple-object-elf.c -- routines to manipulate ELF object files.
2 Copyright (C) 2010-2017 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor, Google.
5 This program is free software; you can redistribute it and/or modify it
6 under the terms of the GNU General Public License as published by the
7 Free Software Foundation; either version 2, or (at your option) any
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, 51 Franklin Street - Fifth Floor,
18 Boston, MA 02110-1301, USA. */
21 #include "libiberty.h"
22 #include "simple-object.h"
39 #ifdef HAVE_INTTYPES_H
43 #include "simple-object-common.h"
45 /* ELF structures and constants. */
47 /* 32-bit ELF file header. */
50 unsigned char e_ident
[16]; /* ELF "magic number" */
51 unsigned char e_type
[2]; /* Identifies object file type */
52 unsigned char e_machine
[2]; /* Specifies required architecture */
53 unsigned char e_version
[4]; /* Identifies object file version */
54 unsigned char e_entry
[4]; /* Entry point virtual address */
55 unsigned char e_phoff
[4]; /* Program header table file offset */
56 unsigned char e_shoff
[4]; /* Section header table file offset */
57 unsigned char e_flags
[4]; /* Processor-specific flags */
58 unsigned char e_ehsize
[2]; /* ELF header size in bytes */
59 unsigned char e_phentsize
[2]; /* Program header table entry size */
60 unsigned char e_phnum
[2]; /* Program header table entry count */
61 unsigned char e_shentsize
[2]; /* Section header table entry size */
62 unsigned char e_shnum
[2]; /* Section header table entry count */
63 unsigned char e_shstrndx
[2]; /* Section header string table index */
64 } Elf32_External_Ehdr
;
66 /* 64-bit ELF file header. */
69 unsigned char e_ident
[16]; /* ELF "magic number" */
70 unsigned char e_type
[2]; /* Identifies object file type */
71 unsigned char e_machine
[2]; /* Specifies required architecture */
72 unsigned char e_version
[4]; /* Identifies object file version */
73 unsigned char e_entry
[8]; /* Entry point virtual address */
74 unsigned char e_phoff
[8]; /* Program header table file offset */
75 unsigned char e_shoff
[8]; /* Section header table file offset */
76 unsigned char e_flags
[4]; /* Processor-specific flags */
77 unsigned char e_ehsize
[2]; /* ELF header size in bytes */
78 unsigned char e_phentsize
[2]; /* Program header table entry size */
79 unsigned char e_phnum
[2]; /* Program header table entry count */
80 unsigned char e_shentsize
[2]; /* Section header table entry size */
81 unsigned char e_shnum
[2]; /* Section header table entry count */
82 unsigned char e_shstrndx
[2]; /* Section header string table index */
83 } Elf64_External_Ehdr
;
85 /* Indexes and values in e_ident field of Ehdr. */
87 #define EI_MAG0 0 /* File identification byte 0 index */
88 #define ELFMAG0 0x7F /* Magic number byte 0 */
90 #define EI_MAG1 1 /* File identification byte 1 index */
91 #define ELFMAG1 'E' /* Magic number byte 1 */
93 #define EI_MAG2 2 /* File identification byte 2 index */
94 #define ELFMAG2 'L' /* Magic number byte 2 */
96 #define EI_MAG3 3 /* File identification byte 3 index */
97 #define ELFMAG3 'F' /* Magic number byte 3 */
99 #define EI_CLASS 4 /* File class */
100 #define ELFCLASSNONE 0 /* Invalid class */
101 #define ELFCLASS32 1 /* 32-bit objects */
102 #define ELFCLASS64 2 /* 64-bit objects */
104 #define EI_DATA 5 /* Data encoding */
105 #define ELFDATANONE 0 /* Invalid data encoding */
106 #define ELFDATA2LSB 1 /* 2's complement, little endian */
107 #define ELFDATA2MSB 2 /* 2's complement, big endian */
109 #define EI_VERSION 6 /* File version */
110 #define EV_CURRENT 1 /* Current version */
112 #define EI_OSABI 7 /* Operating System/ABI indication */
114 /* Values for e_type field of Ehdr. */
116 #define ET_REL 1 /* Relocatable file */
118 /* Values for e_machine field of Ehdr. */
120 #define EM_SPARC 2 /* SUN SPARC */
121 #define EM_SPARC32PLUS 18 /* Sun's "v8plus" */
123 /* Special section index values. */
125 #define SHN_UNDEF 0 /* Undefined section */
126 #define SHN_LORESERVE 0xFF00 /* Begin range of reserved indices */
127 #define SHN_COMMON 0xFFF2 /* Associated symbol is in common */
128 #define SHN_XINDEX 0xFFFF /* Section index is held elsewhere */
131 /* 32-bit ELF program header. */
134 unsigned char p_type
[4]; /* Identifies program segment type */
135 unsigned char p_offset
[4]; /* Segment file offset */
136 unsigned char p_vaddr
[4]; /* Segment virtual address */
137 unsigned char p_paddr
[4]; /* Segment physical address */
138 unsigned char p_filesz
[4]; /* Segment size in file */
139 unsigned char p_memsz
[4]; /* Segment size in memory */
140 unsigned char p_flags
[4]; /* Segment flags */
141 unsigned char p_align
[4]; /* Segment alignment, file & memory */
142 } Elf32_External_Phdr
;
144 /* 64-bit ELF program header. */
147 unsigned char p_type
[4]; /* Identifies program segment type */
148 unsigned char p_flags
[4]; /* Segment flags */
149 unsigned char p_offset
[8]; /* Segment file offset */
150 unsigned char p_vaddr
[8]; /* Segment virtual address */
151 unsigned char p_paddr
[8]; /* Segment physical address */
152 unsigned char p_filesz
[8]; /* Segment size in file */
153 unsigned char p_memsz
[8]; /* Segment size in memory */
154 unsigned char p_align
[8]; /* Segment alignment, file & memory */
155 } Elf64_External_Phdr
;
157 /* 32-bit ELF section header */
160 unsigned char sh_name
[4]; /* Section name, index in string tbl */
161 unsigned char sh_type
[4]; /* Type of section */
162 unsigned char sh_flags
[4]; /* Miscellaneous section attributes */
163 unsigned char sh_addr
[4]; /* Section virtual addr at execution */
164 unsigned char sh_offset
[4]; /* Section file offset */
165 unsigned char sh_size
[4]; /* Size of section in bytes */
166 unsigned char sh_link
[4]; /* Index of another section */
167 unsigned char sh_info
[4]; /* Additional section information */
168 unsigned char sh_addralign
[4]; /* Section alignment */
169 unsigned char sh_entsize
[4]; /* Entry size if section holds table */
170 } Elf32_External_Shdr
;
172 /* 64-bit ELF section header. */
175 unsigned char sh_name
[4]; /* Section name, index in string tbl */
176 unsigned char sh_type
[4]; /* Type of section */
177 unsigned char sh_flags
[8]; /* Miscellaneous section attributes */
178 unsigned char sh_addr
[8]; /* Section virtual addr at execution */
179 unsigned char sh_offset
[8]; /* Section file offset */
180 unsigned char sh_size
[8]; /* Size of section in bytes */
181 unsigned char sh_link
[4]; /* Index of another section */
182 unsigned char sh_info
[4]; /* Additional section information */
183 unsigned char sh_addralign
[8]; /* Section alignment */
184 unsigned char sh_entsize
[8]; /* Entry size if section holds table */
185 } Elf64_External_Shdr
;
187 /* Values for sh_type field. */
189 #define SHT_NULL 0 /* Section header table entry unused */
190 #define SHT_PROGBITS 1 /* Program data */
191 #define SHT_SYMTAB 2 /* Link editing symbol table */
192 #define SHT_STRTAB 3 /* A string table */
193 #define SHT_RELA 4 /* Relocation entries with addends */
194 #define SHT_REL 9 /* Relocation entries, no addends */
195 #define SHT_GROUP 17 /* Section contains a section group */
197 /* Values for sh_flags field. */
199 #define SHF_EXCLUDE 0x80000000 /* Link editor is to exclude this
200 section from executable and
201 shared library that it builds
202 when those objects are not to be
203 further relocated. */
204 /* Symbol table entry. */
208 unsigned char st_name
[4]; /* Symbol name (string tbl index) */
209 unsigned char st_value
[4]; /* Symbol value */
210 unsigned char st_size
[4]; /* Symbol size */
211 unsigned char st_info
; /* Symbol type and binding */
212 unsigned char st_other
; /* Symbol visibility */
213 unsigned char st_shndx
[2]; /* Section index */
214 } Elf32_External_Sym
;
218 unsigned char st_name
[4]; /* Symbol name (string tbl index) */
219 unsigned char st_info
; /* Symbol type and binding */
220 unsigned char st_other
; /* Symbol visibility */
221 unsigned char st_shndx
[2]; /* Section index */
222 unsigned char st_value
[8]; /* Symbol value */
223 unsigned char st_size
[8]; /* Symbol size */
224 } Elf64_External_Sym
;
226 #define ELF_ST_BIND(val) (((unsigned char) (val)) >> 4)
227 #define ELF_ST_TYPE(val) ((val) & 0xf)
228 #define ELF_ST_INFO(bind, type) (((bind) << 4) + ((type) & 0xf))
230 #define STT_NOTYPE 0 /* Symbol type is unspecified */
231 #define STT_OBJECT 1 /* Symbol is a data object */
232 #define STT_FUNC 2 /* Symbol is a code object */
233 #define STT_TLS 6 /* Thread local data object */
234 #define STT_GNU_IFUNC 10 /* Symbol is an indirect code object */
236 #define STB_LOCAL 0 /* Local symbol */
237 #define STB_GLOBAL 1 /* Global symbol */
239 #define STV_DEFAULT 0 /* Visibility is specified by binding type */
241 /* Functions to fetch and store different ELF types, depending on the
242 endianness and size. */
244 struct elf_type_functions
246 unsigned short (*fetch_Elf_Half
) (const unsigned char *);
247 unsigned int (*fetch_Elf_Word
) (const unsigned char *);
248 ulong_type (*fetch_Elf_Addr
) (const unsigned char *);
249 void (*set_Elf_Half
) (unsigned char *, unsigned short);
250 void (*set_Elf_Word
) (unsigned char *, unsigned int);
251 void (*set_Elf_Addr
) (unsigned char *, ulong_type
);
254 static const struct elf_type_functions elf_big_32_functions
=
256 simple_object_fetch_big_16
,
257 simple_object_fetch_big_32
,
258 simple_object_fetch_big_32_ulong
,
259 simple_object_set_big_16
,
260 simple_object_set_big_32
,
261 simple_object_set_big_32_ulong
264 static const struct elf_type_functions elf_little_32_functions
=
266 simple_object_fetch_little_16
,
267 simple_object_fetch_little_32
,
268 simple_object_fetch_little_32_ulong
,
269 simple_object_set_little_16
,
270 simple_object_set_little_32
,
271 simple_object_set_little_32_ulong
274 #ifdef UNSIGNED_64BIT_TYPE
276 static const struct elf_type_functions elf_big_64_functions
=
278 simple_object_fetch_big_16
,
279 simple_object_fetch_big_32
,
280 simple_object_fetch_big_64
,
281 simple_object_set_big_16
,
282 simple_object_set_big_32
,
283 simple_object_set_big_64
286 static const struct elf_type_functions elf_little_64_functions
=
288 simple_object_fetch_little_16
,
289 simple_object_fetch_little_32
,
290 simple_object_fetch_little_64
,
291 simple_object_set_little_16
,
292 simple_object_set_little_32
,
293 simple_object_set_little_64
298 /* Hideous macro to fetch the value of a field from an external ELF
299 struct of some sort. TYPEFUNCS is the set of type functions.
300 BUFFER points to the external data. STRUCTTYPE is the appropriate
301 struct type. FIELD is a field within the struct. TYPE is the type
302 of the field in the struct: Elf_Half, Elf_Word, or Elf_Addr. */
304 #define ELF_FETCH_STRUCT_FIELD(TYPEFUNCS, STRUCTTYPE, FIELD, BUFFER, TYPE) \
305 ((TYPEFUNCS)->fetch_ ## TYPE ((BUFFER) + offsetof (STRUCTTYPE, FIELD)))
307 /* Even more hideous macro to fetch the value of FIELD from BUFFER.
308 SIZE is 32 or 64. STRUCTTYPE is the name of the struct from
309 elf/external.h: Ehdr, Shdr, etc. FIELD is the name of a field in
310 the struct. TYPE is the type of the field in the struct: Elf_Half,
311 Elf_Word, or Elf_Addr. */
313 #define ELF_FETCH_SIZED_FIELD(TYPEFUNCS, SIZE, STRUCTTYPE, BUFFER, \
315 ELF_FETCH_STRUCT_FIELD (TYPEFUNCS, \
316 Elf ## SIZE ## _External_ ## STRUCTTYPE, \
319 /* Like ELF_FETCH_SIZED_FIELD but taking an ELFCLASS value. */
321 #define ELF_FETCH_FIELD(TYPEFUNCS, CLASS, STRUCTTYPE, BUFFER, \
323 ((CLASS) == ELFCLASS32 \
324 ? ELF_FETCH_SIZED_FIELD (TYPEFUNCS, 32, STRUCTTYPE, BUFFER, FIELD, \
326 : ELF_FETCH_SIZED_FIELD (TYPEFUNCS, 64, STRUCTTYPE, BUFFER, FIELD, \
329 /* Hideous macro to set the value of a field in an external ELF
330 structure to VAL. TYPEFUNCS is the set of type functions. BUFFER
331 points to the external data. STRUCTTYPE is the appropriate
332 structure type. FIELD is a field within the struct. TYPE is the
333 type of the field in the struct: Elf_Half, Elf_Word, or
336 #define ELF_SET_STRUCT_FIELD(TYPEFUNCS, STRUCTTYPE, FIELD, BUFFER, TYPE, VAL) \
337 (TYPEFUNCS)->set_ ## TYPE ((BUFFER) + offsetof (STRUCTTYPE, FIELD), (VAL))
339 /* Even more hideous macro to set the value of FIELD in BUFFER to VAL.
340 SIZE is 32 or 64. STRUCTTYPE is the name of the struct from
341 elf/external.h: Ehdr, Shdr, etc. FIELD is the name of a field in
342 the struct. TYPE is the type of the field in the struct: Elf_Half,
343 Elf_Word, or Elf_Addr. */
345 #define ELF_SET_SIZED_FIELD(TYPEFUNCS, SIZE, STRUCTTYPE, BUFFER, FIELD, \
347 ELF_SET_STRUCT_FIELD (TYPEFUNCS, \
348 Elf ## SIZE ## _External_ ## STRUCTTYPE, \
349 FIELD, BUFFER, TYPE, VAL)
351 /* Like ELF_SET_SIZED_FIELD but taking an ELFCLASS value. */
353 #define ELF_SET_FIELD(TYPEFUNCS, CLASS, STRUCTTYPE, BUFFER, FIELD, \
355 ((CLASS) == ELFCLASS32 \
356 ? ELF_SET_SIZED_FIELD (TYPEFUNCS, 32, STRUCTTYPE, BUFFER, FIELD, \
358 : ELF_SET_SIZED_FIELD (TYPEFUNCS, 64, STRUCTTYPE, BUFFER, FIELD, \
361 /* Private data for an simple_object_read. */
363 struct simple_object_elf_read
365 /* Type functions. */
366 const struct elf_type_functions
* type_functions
;
368 unsigned char ei_data
;
370 unsigned char ei_class
;
372 unsigned char ei_osabi
;
373 /* Elf machine number. */
374 unsigned short machine
;
375 /* Processor specific flags. */
377 /* File offset of section headers. */
379 /* Number of sections. */
381 /* Index of string table section header. */
382 unsigned int shstrndx
;
385 /* Private data for an simple_object_attributes. */
387 struct simple_object_elf_attributes
389 /* Type functions. */
390 const struct elf_type_functions
* type_functions
;
392 unsigned char ei_data
;
394 unsigned char ei_class
;
396 unsigned char ei_osabi
;
397 /* Elf machine number. */
398 unsigned short machine
;
399 /* Processor specific flags. */
403 /* Private data for an simple_object_write. */
405 struct simple_object_elf_write
407 struct simple_object_elf_attributes attrs
;
408 unsigned char *shdrs
;
411 /* See if we have an ELF file. */
414 simple_object_elf_match (unsigned char header
[SIMPLE_OBJECT_MATCH_HEADER_LEN
],
415 int descriptor
, off_t offset
,
416 const char *segment_name ATTRIBUTE_UNUSED
,
417 const char **errmsg
, int *err
)
419 unsigned char ei_data
;
420 unsigned char ei_class
;
421 const struct elf_type_functions
*type_functions
;
422 unsigned char ehdr
[sizeof (Elf64_External_Ehdr
)];
423 struct simple_object_elf_read
*eor
;
425 if (header
[EI_MAG0
] != ELFMAG0
426 || header
[EI_MAG1
] != ELFMAG1
427 || header
[EI_MAG2
] != ELFMAG2
428 || header
[EI_MAG3
] != ELFMAG3
429 || header
[EI_VERSION
] != EV_CURRENT
)
436 ei_data
= header
[EI_DATA
];
437 if (ei_data
!= ELFDATA2LSB
&& ei_data
!= ELFDATA2MSB
)
439 *errmsg
= "unknown ELF endianness";
444 ei_class
= header
[EI_CLASS
];
448 type_functions
= (ei_data
== ELFDATA2LSB
449 ? &elf_little_32_functions
450 : &elf_big_32_functions
);
454 #ifndef UNSIGNED_64BIT_TYPE
455 *errmsg
= "64-bit ELF objects not supported";
459 type_functions
= (ei_data
== ELFDATA2LSB
460 ? &elf_little_64_functions
461 : &elf_big_64_functions
);
466 *errmsg
= "unrecognized ELF size";
471 if (!simple_object_internal_read (descriptor
, offset
, ehdr
, sizeof ehdr
,
475 eor
= XNEW (struct simple_object_elf_read
);
476 eor
->type_functions
= type_functions
;
477 eor
->ei_data
= ei_data
;
478 eor
->ei_class
= ei_class
;
479 eor
->ei_osabi
= header
[EI_OSABI
];
480 eor
->machine
= ELF_FETCH_FIELD (type_functions
, ei_class
, Ehdr
, ehdr
,
481 e_machine
, Elf_Half
);
482 eor
->flags
= ELF_FETCH_FIELD (type_functions
, ei_class
, Ehdr
, ehdr
,
484 eor
->shoff
= ELF_FETCH_FIELD (type_functions
, ei_class
, Ehdr
, ehdr
,
486 eor
->shnum
= ELF_FETCH_FIELD (type_functions
, ei_class
, Ehdr
, ehdr
,
488 eor
->shstrndx
= ELF_FETCH_FIELD (type_functions
, ei_class
, Ehdr
, ehdr
,
489 e_shstrndx
, Elf_Half
);
491 if ((eor
->shnum
== 0 || eor
->shstrndx
== SHN_XINDEX
)
494 unsigned char shdr
[sizeof (Elf64_External_Shdr
)];
496 /* Object file has more than 0xffff sections. */
498 if (!simple_object_internal_read (descriptor
, offset
+ eor
->shoff
, shdr
,
499 (ei_class
== ELFCLASS32
500 ? sizeof (Elf32_External_Shdr
)
501 : sizeof (Elf64_External_Shdr
)),
509 eor
->shnum
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
510 shdr
, sh_size
, Elf_Addr
);
512 if (eor
->shstrndx
== SHN_XINDEX
)
514 eor
->shstrndx
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
515 shdr
, sh_link
, Elf_Word
);
517 /* Versions of the GNU binutils between 2.12 and 2.18 did
518 not handle objects with more than SHN_LORESERVE sections
519 correctly. All large section indexes were offset by
520 0x100. There is more information at
521 http://sourceware.org/bugzilla/show_bug.cgi?id-5900 .
522 Fortunately these object files are easy to detect, as the
523 GNU binutils always put the section header string table
524 near the end of the list of sections. Thus if the
525 section header string table index is larger than the
526 number of sections, then we know we have to subtract
527 0x100 to get the real section index. */
528 if (eor
->shstrndx
>= eor
->shnum
529 && eor
->shstrndx
>= SHN_LORESERVE
+ 0x100)
530 eor
->shstrndx
-= 0x100;
534 if (eor
->shstrndx
>= eor
->shnum
)
536 *errmsg
= "invalid ELF shstrndx >= shnum";
545 /* Find all sections in an ELF file. */
548 simple_object_elf_find_sections (simple_object_read
*sobj
,
549 int (*pfn
) (void *, const char *,
550 off_t offset
, off_t length
),
554 struct simple_object_elf_read
*eor
=
555 (struct simple_object_elf_read
*) sobj
->data
;
556 const struct elf_type_functions
*type_functions
= eor
->type_functions
;
557 unsigned char ei_class
= eor
->ei_class
;
560 unsigned char *shdrs
;
562 unsigned char *shstrhdr
;
565 unsigned char *names
;
568 shdr_size
= (ei_class
== ELFCLASS32
569 ? sizeof (Elf32_External_Shdr
)
570 : sizeof (Elf64_External_Shdr
));
572 /* Read the section headers. We skip section 0, which is not a
576 shdrs
= XNEWVEC (unsigned char, shdr_size
* (shnum
- 1));
578 if (!simple_object_internal_read (sobj
->descriptor
,
579 sobj
->offset
+ eor
->shoff
+ shdr_size
,
581 shdr_size
* (shnum
- 1),
588 /* Read the section names. */
590 if (eor
->shstrndx
== 0)
593 return "ELF section header string table missing";
595 shstrhdr
= shdrs
+ (eor
->shstrndx
- 1) * shdr_size
;
596 name_size
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
597 shstrhdr
, sh_size
, Elf_Addr
);
598 shstroff
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
599 shstrhdr
, sh_offset
, Elf_Addr
);
600 names
= XNEWVEC (unsigned char, name_size
);
601 if (!simple_object_internal_read (sobj
->descriptor
,
602 sobj
->offset
+ shstroff
,
603 names
, name_size
, &errmsg
, err
))
610 for (i
= 1; i
< shnum
; ++i
)
613 unsigned int sh_name
;
618 shdr
= shdrs
+ (i
- 1) * shdr_size
;
619 sh_name
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
620 shdr
, sh_name
, Elf_Word
);
621 if (sh_name
>= name_size
)
626 return "ELF section name out of range";
629 name
= (const char *) names
+ sh_name
;
630 offset
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
631 shdr
, sh_offset
, Elf_Addr
);
632 length
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
633 shdr
, sh_size
, Elf_Addr
);
635 if (!(*pfn
) (data
, name
, offset
, length
))
645 /* Fetch the attributes for an simple_object_read. */
648 simple_object_elf_fetch_attributes (simple_object_read
*sobj
,
649 const char **errmsg ATTRIBUTE_UNUSED
,
650 int *err ATTRIBUTE_UNUSED
)
652 struct simple_object_elf_read
*eor
=
653 (struct simple_object_elf_read
*) sobj
->data
;
654 struct simple_object_elf_attributes
*ret
;
656 ret
= XNEW (struct simple_object_elf_attributes
);
657 ret
->type_functions
= eor
->type_functions
;
658 ret
->ei_data
= eor
->ei_data
;
659 ret
->ei_class
= eor
->ei_class
;
660 ret
->ei_osabi
= eor
->ei_osabi
;
661 ret
->machine
= eor
->machine
;
662 ret
->flags
= eor
->flags
;
666 /* Release the privata data for an simple_object_read. */
669 simple_object_elf_release_read (void *data
)
674 /* Compare two attributes structures. */
677 simple_object_elf_attributes_merge (void *todata
, void *fromdata
, int *err
)
679 struct simple_object_elf_attributes
*to
=
680 (struct simple_object_elf_attributes
*) todata
;
681 struct simple_object_elf_attributes
*from
=
682 (struct simple_object_elf_attributes
*) fromdata
;
684 if (to
->ei_data
!= from
->ei_data
|| to
->ei_class
!= from
->ei_class
)
687 return "ELF object format mismatch";
690 if (to
->machine
!= from
->machine
)
694 /* EM_SPARC and EM_SPARC32PLUS are compatible and force an
695 output of EM_SPARC32PLUS. */
700 if (from
->machine
== EM_SPARC32PLUS
)
702 to
->machine
= from
->machine
;
708 if (from
->machine
== EM_SPARC
)
719 return "ELF machine number mismatch";
726 /* Release the private data for an attributes structure. */
729 simple_object_elf_release_attributes (void *data
)
734 /* Prepare to write out a file. */
737 simple_object_elf_start_write (void *attributes_data
,
738 const char **errmsg ATTRIBUTE_UNUSED
,
739 int *err ATTRIBUTE_UNUSED
)
741 struct simple_object_elf_attributes
*attrs
=
742 (struct simple_object_elf_attributes
*) attributes_data
;
743 struct simple_object_elf_write
*ret
;
745 /* We're just going to record the attributes, but we need to make a
746 copy because the user may delete them. */
747 ret
= XNEW (struct simple_object_elf_write
);
753 /* Write out an ELF ehdr. */
756 simple_object_elf_write_ehdr (simple_object_write
*sobj
, int descriptor
,
757 const char **errmsg
, int *err
)
759 struct simple_object_elf_attributes
*attrs
=
760 (struct simple_object_elf_attributes
*) sobj
->data
;
761 const struct elf_type_functions
* fns
;
764 unsigned char buf
[sizeof (Elf64_External_Ehdr
)];
765 simple_object_write_section
*section
;
767 unsigned int shstrndx
;
769 fns
= attrs
->type_functions
;
770 cl
= attrs
->ei_class
;
773 for (section
= sobj
->sections
; section
!= NULL
; section
= section
->next
)
777 /* Add a section header for the dummy section and one for
782 ehdr_size
= (cl
== ELFCLASS32
783 ? sizeof (Elf32_External_Ehdr
)
784 : sizeof (Elf64_External_Ehdr
));
785 memset (buf
, 0, sizeof (Elf64_External_Ehdr
));
787 buf
[EI_MAG0
] = ELFMAG0
;
788 buf
[EI_MAG1
] = ELFMAG1
;
789 buf
[EI_MAG2
] = ELFMAG2
;
790 buf
[EI_MAG3
] = ELFMAG3
;
792 buf
[EI_DATA
] = attrs
->ei_data
;
793 buf
[EI_VERSION
] = EV_CURRENT
;
794 buf
[EI_OSABI
] = attrs
->ei_osabi
;
796 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_type
, Elf_Half
, ET_REL
);
797 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_machine
, Elf_Half
, attrs
->machine
);
798 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_version
, Elf_Word
, EV_CURRENT
);
799 /* e_entry left as zero. */
800 /* e_phoff left as zero. */
801 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_shoff
, Elf_Addr
, ehdr_size
);
802 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_flags
, Elf_Word
, attrs
->flags
);
803 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_ehsize
, Elf_Half
, ehdr_size
);
804 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_phentsize
, Elf_Half
,
806 ? sizeof (Elf32_External_Phdr
)
807 : sizeof (Elf64_External_Phdr
)));
808 /* e_phnum left as zero. */
809 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_shentsize
, Elf_Half
,
811 ? sizeof (Elf32_External_Shdr
)
812 : sizeof (Elf64_External_Shdr
)));
813 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_shnum
, Elf_Half
,
814 shnum
>= SHN_LORESERVE
? 0 : shnum
);
819 shstrndx
= shnum
- 1;
820 if (shstrndx
>= SHN_LORESERVE
)
821 shstrndx
= SHN_XINDEX
;
823 ELF_SET_FIELD (fns
, cl
, Ehdr
, buf
, e_shstrndx
, Elf_Half
, shstrndx
);
825 return simple_object_internal_write (descriptor
, 0, buf
, ehdr_size
,
829 /* Write out an ELF shdr. */
832 simple_object_elf_write_shdr (simple_object_write
*sobj
, int descriptor
,
833 off_t offset
, unsigned int sh_name
,
834 unsigned int sh_type
, unsigned int sh_flags
,
836 unsigned int sh_offset
, unsigned int sh_size
,
837 unsigned int sh_link
, unsigned int sh_info
,
840 const char **errmsg
, int *err
)
842 struct simple_object_elf_attributes
*attrs
=
843 (struct simple_object_elf_attributes
*) sobj
->data
;
844 const struct elf_type_functions
* fns
;
847 unsigned char buf
[sizeof (Elf64_External_Shdr
)];
849 fns
= attrs
->type_functions
;
850 cl
= attrs
->ei_class
;
852 shdr_size
= (cl
== ELFCLASS32
853 ? sizeof (Elf32_External_Shdr
)
854 : sizeof (Elf64_External_Shdr
));
855 memset (buf
, 0, sizeof (Elf64_External_Shdr
));
857 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_name
, Elf_Word
, sh_name
);
858 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_type
, Elf_Word
, sh_type
);
859 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_flags
, Elf_Addr
, sh_flags
);
860 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_addr
, Elf_Addr
, sh_addr
);
861 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_offset
, Elf_Addr
, sh_offset
);
862 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_size
, Elf_Addr
, sh_size
);
863 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_link
, Elf_Word
, sh_link
);
864 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_info
, Elf_Word
, sh_info
);
865 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_addralign
, Elf_Addr
, sh_addralign
);
866 ELF_SET_FIELD (fns
, cl
, Shdr
, buf
, sh_entsize
, Elf_Addr
, sh_entsize
);
868 return simple_object_internal_write (descriptor
, offset
, buf
, shdr_size
,
872 /* Write out a complete ELF file.
877 user-created section data
881 simple_object_elf_write_to_file (simple_object_write
*sobj
, int descriptor
,
884 struct simple_object_elf_write
*eow
=
885 (struct simple_object_elf_write
*) sobj
->data
;
886 struct simple_object_elf_attributes
*attrs
= &eow
->attrs
;
891 simple_object_write_section
*section
;
895 unsigned int first_sh_size
;
896 unsigned int first_sh_link
;
901 if (!simple_object_elf_write_ehdr (sobj
, descriptor
, &errmsg
, err
))
904 cl
= attrs
->ei_class
;
905 if (cl
== ELFCLASS32
)
907 ehdr_size
= sizeof (Elf32_External_Ehdr
);
908 shdr_size
= sizeof (Elf32_External_Shdr
);
912 ehdr_size
= sizeof (Elf64_External_Ehdr
);
913 shdr_size
= sizeof (Elf64_External_Shdr
);
917 for (section
= sobj
->sections
; section
!= NULL
; section
= section
->next
)
922 /* Add initial dummy Shdr and .shstrtab. */
925 shdr_offset
= ehdr_size
;
926 sh_offset
= shdr_offset
+ shnum
* shdr_size
;
928 if (shnum
< SHN_LORESERVE
)
931 first_sh_size
= shnum
;
932 if (shnum
- 1 < SHN_LORESERVE
)
935 first_sh_link
= shnum
- 1;
936 if (!simple_object_elf_write_shdr (sobj
, descriptor
, shdr_offset
,
937 0, 0, 0, 0, 0, first_sh_size
, first_sh_link
,
938 0, 0, 0, &errmsg
, err
))
941 shdr_offset
+= shdr_size
;
945 for (section
= sobj
->sections
; section
!= NULL
; section
= section
->next
)
948 size_t new_sh_offset
;
950 struct simple_object_write_section_buffer
*buffer
;
951 unsigned int sh_type
= SHT_PROGBITS
;
952 unsigned int sh_flags
= 0;
954 unsigned int sh_link
= 0;
955 unsigned int sh_info
= 0;
956 size_t sh_addralign
= 1U << section
->align
;
957 size_t sh_entsize
= 0;
960 sh_type
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
961 eow
->shdrs
+ secnum
* shdr_size
,
963 sh_flags
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
964 eow
->shdrs
+ secnum
* shdr_size
,
966 sh_addr
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
967 eow
->shdrs
+ secnum
* shdr_size
,
969 sh_link
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
970 eow
->shdrs
+ secnum
* shdr_size
,
972 sh_info
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
973 eow
->shdrs
+ secnum
* shdr_size
,
975 sh_addralign
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
976 eow
->shdrs
+ secnum
* shdr_size
,
977 sh_addralign
, Elf_Addr
);
978 sh_entsize
= ELF_FETCH_FIELD (attrs
->type_functions
, attrs
->ei_class
, Shdr
,
979 eow
->shdrs
+ secnum
* shdr_size
,
980 sh_entsize
, Elf_Addr
);
984 mask
= sh_addralign
- 1;
985 new_sh_offset
= sh_offset
+ mask
;
986 new_sh_offset
&= ~ mask
;
987 while (new_sh_offset
> sh_offset
)
989 unsigned char zeroes
[16];
992 memset (zeroes
, 0, sizeof zeroes
);
993 write
= new_sh_offset
- sh_offset
;
994 if (write
> sizeof zeroes
)
995 write
= sizeof zeroes
;
996 if (!simple_object_internal_write (descriptor
, sh_offset
, zeroes
,
997 write
, &errmsg
, err
))
1003 for (buffer
= section
->buffers
; buffer
!= NULL
; buffer
= buffer
->next
)
1005 if (!simple_object_internal_write (descriptor
, sh_offset
+ sh_size
,
1006 ((const unsigned char *)
1008 buffer
->size
, &errmsg
, err
))
1010 sh_size
+= buffer
->size
;
1013 if (!simple_object_elf_write_shdr (sobj
, descriptor
, shdr_offset
,
1014 sh_name
, sh_type
, sh_flags
,
1016 sh_size
, sh_link
, sh_info
,
1017 sh_addralign
, sh_entsize
,
1021 shdr_offset
+= shdr_size
;
1022 sh_name
+= strlen (section
->name
) + 1;
1023 sh_offset
+= sh_size
;
1026 if (!simple_object_elf_write_shdr (sobj
, descriptor
, shdr_offset
,
1027 sh_name
, SHT_STRTAB
, 0, 0, sh_offset
,
1028 sh_name
+ strlen (".shstrtab") + 1, 0, 0,
1029 1, 0, &errmsg
, err
))
1032 /* .shstrtab has a leading zero byte. */
1034 if (!simple_object_internal_write (descriptor
, sh_offset
, &zero
, 1,
1039 for (section
= sobj
->sections
; section
!= NULL
; section
= section
->next
)
1043 len
= strlen (section
->name
) + 1;
1044 if (!simple_object_internal_write (descriptor
, sh_offset
,
1045 (const unsigned char *) section
->name
,
1051 if (!simple_object_internal_write (descriptor
, sh_offset
,
1052 (const unsigned char *) ".shstrtab",
1053 strlen (".shstrtab") + 1, &errmsg
, err
))
1059 /* Release the private data for an simple_object_write structure. */
1062 simple_object_elf_release_write (void *data
)
1064 struct simple_object_elf_write
*eow
= (struct simple_object_elf_write
*) data
;
1066 XDELETE (eow
->shdrs
);
1070 /* Copy all sections in an ELF file. */
1073 simple_object_elf_copy_lto_debug_sections (simple_object_read
*sobj
,
1074 simple_object_write
*dobj
,
1075 int (*pfn
) (const char **),
1078 struct simple_object_elf_read
*eor
=
1079 (struct simple_object_elf_read
*) sobj
->data
;
1080 const struct elf_type_functions
*type_functions
= eor
->type_functions
;
1081 struct simple_object_elf_write
*eow
=
1082 (struct simple_object_elf_write
*) dobj
->data
;
1083 unsigned char ei_class
= eor
->ei_class
;
1086 unsigned char *shdrs
;
1088 unsigned char *shstrhdr
;
1091 unsigned char *names
;
1094 const char **pfnname
;
1096 shdr_size
= (ei_class
== ELFCLASS32
1097 ? sizeof (Elf32_External_Shdr
)
1098 : sizeof (Elf64_External_Shdr
));
1100 /* Read the section headers. We skip section 0, which is not a
1104 shdrs
= XNEWVEC (unsigned char, shdr_size
* (shnum
- 1));
1106 if (!simple_object_internal_read (sobj
->descriptor
,
1107 sobj
->offset
+ eor
->shoff
+ shdr_size
,
1109 shdr_size
* (shnum
- 1),
1116 /* Read the section names. */
1118 shstrhdr
= shdrs
+ (eor
->shstrndx
- 1) * shdr_size
;
1119 name_size
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1120 shstrhdr
, sh_size
, Elf_Addr
);
1121 shstroff
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1122 shstrhdr
, sh_offset
, Elf_Addr
);
1123 names
= XNEWVEC (unsigned char, name_size
);
1124 if (!simple_object_internal_read (sobj
->descriptor
,
1125 sobj
->offset
+ shstroff
,
1126 names
, name_size
, &errmsg
, err
))
1133 eow
->shdrs
= XNEWVEC (unsigned char, shdr_size
* (shnum
- 1));
1134 pfnret
= XNEWVEC (int, shnum
);
1135 pfnname
= XNEWVEC (const char *, shnum
);
1137 /* First perform the callbacks to know which sections to preserve and
1138 what name to use for those. */
1139 for (i
= 1; i
< shnum
; ++i
)
1141 unsigned char *shdr
;
1142 unsigned int sh_name
;
1146 shdr
= shdrs
+ (i
- 1) * shdr_size
;
1147 sh_name
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1148 shdr
, sh_name
, Elf_Word
);
1149 if (sh_name
>= name_size
)
1154 return "ELF section name out of range";
1157 name
= (const char *) names
+ sh_name
;
1159 ret
= (*pfn
) (&name
);
1160 pfnret
[i
- 1] = ret
== 1 ? 0 : -1;
1161 pfnname
[i
- 1] = name
;
1164 /* Mark sections as preserved that are required by to be preserved
1166 for (i
= 1; i
< shnum
; ++i
)
1168 unsigned char *shdr
;
1169 unsigned int sh_type
, sh_info
, sh_link
;
1173 shdr
= shdrs
+ (i
- 1) * shdr_size
;
1174 sh_type
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1175 shdr
, sh_type
, Elf_Word
);
1176 sh_info
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1177 shdr
, sh_info
, Elf_Word
);
1178 sh_link
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1179 shdr
, sh_link
, Elf_Word
);
1180 if (sh_type
== SHT_GROUP
)
1182 /* Mark groups containing copied sections. */
1183 unsigned entsize
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1184 shdr
, sh_entsize
, Elf_Addr
);
1185 unsigned char *ent
, *buf
;
1187 offset
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1188 shdr
, sh_offset
, Elf_Addr
);
1189 length
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1190 shdr
, sh_size
, Elf_Addr
);
1191 buf
= XNEWVEC (unsigned char, length
);
1192 if (!simple_object_internal_read (sobj
->descriptor
,
1193 sobj
->offset
+ offset
, buf
,
1194 (size_t) length
, &errmsg
, err
))
1201 for (ent
= buf
+ entsize
; ent
< buf
+ length
; ent
+= entsize
)
1203 unsigned sec
= type_functions
->fetch_Elf_Word (ent
);
1204 if (pfnret
[sec
- 1] == 0)
1209 pfnret
[sh_link
- 1] = 0;
1213 if (sh_type
== SHT_RELA
1214 || sh_type
== SHT_REL
)
1216 /* Mark relocation sections and symtab of copied sections. */
1217 if (pfnret
[sh_info
- 1] == 0)
1219 pfnret
[sh_link
- 1] = 0;
1223 if (sh_type
== SHT_SYMTAB
)
1225 /* Mark strings sections of copied symtabs. */
1226 if (pfnret
[i
- 1] == 0)
1227 pfnret
[sh_link
- 1] = 0;
1231 /* Then perform the actual copying. */
1232 for (i
= 1; i
< shnum
; ++i
)
1234 unsigned char *shdr
;
1235 unsigned int sh_name
, sh_type
;
1241 simple_object_write_section
*dest
;
1245 shdr
= shdrs
+ (i
- 1) * shdr_size
;
1246 sh_name
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1247 shdr
, sh_name
, Elf_Word
);
1248 if (sh_name
>= name_size
)
1253 return "ELF section name out of range";
1256 name
= (const char *) names
+ sh_name
;
1257 offset
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1258 shdr
, sh_offset
, Elf_Addr
);
1259 length
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1260 shdr
, sh_size
, Elf_Addr
);
1261 sh_type
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1262 shdr
, sh_type
, Elf_Word
);
1264 ret
= pfnret
[i
- 1];
1265 name
= ret
== 0 ? pfnname
[i
- 1] : "";
1267 dest
= simple_object_write_create_section (dobj
, name
, 0, &errmsg
, err
);
1275 /* Record the SHDR of the source. */
1276 memcpy (eow
->shdrs
+ (i
- 1) * shdr_size
, shdr
, shdr_size
);
1277 shdr
= eow
->shdrs
+ (i
- 1) * shdr_size
;
1280 ??? This is quite wasteful and ideally would be delayed until
1281 write_to_file (). Thus it questions the interfacing
1282 which eventually should contain destination creation plus
1284 /* Keep empty sections for sections we should discard. This avoids
1285 the need to rewrite section indices in symtab and relocation
1289 buf
= XNEWVEC (unsigned char, length
);
1290 if (!simple_object_internal_read (sobj
->descriptor
,
1291 sobj
->offset
+ offset
, buf
,
1292 (size_t) length
, &errmsg
, err
))
1300 /* If we are processing .symtab purge __gnu_lto_v1 and
1301 __gnu_lto_slim symbols from it. */
1302 if (sh_type
== SHT_SYMTAB
)
1304 unsigned entsize
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1305 shdr
, sh_entsize
, Elf_Addr
);
1306 unsigned strtab
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1307 shdr
, sh_link
, Elf_Word
);
1308 unsigned char *strshdr
= shdrs
+ (strtab
- 1) * shdr_size
;
1309 off_t stroff
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1310 strshdr
, sh_offset
, Elf_Addr
);
1311 size_t strsz
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1312 strshdr
, sh_size
, Elf_Addr
);
1313 char *strings
= XNEWVEC (char, strsz
);
1315 simple_object_internal_read (sobj
->descriptor
,
1316 sobj
->offset
+ stroff
,
1317 (unsigned char *)strings
,
1318 strsz
, &errmsg
, err
);
1319 for (ent
= buf
; ent
< buf
+ length
; ent
+= entsize
)
1321 unsigned st_shndx
= ELF_FETCH_FIELD (type_functions
, ei_class
,
1323 st_shndx
, Elf_Half
);
1324 unsigned char *st_info
;
1325 unsigned char *st_other
;
1327 if (ei_class
== ELFCLASS32
)
1329 st_info
= &((Elf32_External_Sym
*)ent
)->st_info
;
1330 st_other
= &((Elf32_External_Sym
*)ent
)->st_other
;
1334 st_info
= &((Elf64_External_Sym
*)ent
)->st_info
;
1335 st_other
= &((Elf64_External_Sym
*)ent
)->st_other
;
1337 /* Eliminate all COMMONs - this includes __gnu_lto_v1
1338 and __gnu_lto_slim which otherwise cause endless
1339 LTO plugin invocation. */
1340 if (st_shndx
== SHN_COMMON
)
1341 /* Setting st_name to "" seems to work to purge
1342 COMMON symbols (in addition to setting their
1345 /* We also need to remove symbols refering to sections
1346 we'll eventually remove as with fat LTO objects
1347 we otherwise get duplicate symbols at final link
1348 (with GNU ld, gold is fine and ignores symbols in
1349 sections marked as EXCLUDE). ld/20513 */
1350 else if (st_shndx
!= SHN_UNDEF
1352 && pfnret
[st_shndx
- 1] == -1)
1357 /* Make discarded symbols undefined and unnamed
1358 in case it is local. */
1359 if (ELF_ST_BIND (*st_info
) == STB_LOCAL
)
1360 ELF_SET_FIELD (type_functions
, ei_class
, Sym
,
1361 ent
, st_name
, Elf_Word
, 0);
1362 ELF_SET_FIELD (type_functions
, ei_class
, Sym
,
1363 ent
, st_value
, Elf_Addr
, 0);
1364 ELF_SET_FIELD (type_functions
, ei_class
, Sym
,
1365 ent
, st_size
, Elf_Word
, 0);
1366 ELF_SET_FIELD (type_functions
, ei_class
, Sym
,
1367 ent
, st_shndx
, Elf_Half
, SHN_UNDEF
);
1368 *st_info
= ELF_ST_INFO (ELF_ST_BIND (*st_info
),
1370 *st_other
= STV_DEFAULT
;
1373 XDELETEVEC (strings
);
1376 errmsg
= simple_object_write_add_data (dobj
, dest
,
1377 buf
, length
, 1, err
);
1388 /* For deleted sections mark the section header table entry as
1389 unused. That allows the link editor to remove it in a partial
1391 ELF_SET_FIELD (type_functions
, ei_class
, Shdr
,
1392 shdr
, sh_type
, Elf_Word
, SHT_NULL
);
1395 flags
= ELF_FETCH_FIELD (type_functions
, ei_class
, Shdr
,
1396 shdr
, sh_flags
, Elf_Addr
);
1398 flags
&= ~SHF_EXCLUDE
;
1400 flags
= SHF_EXCLUDE
;
1401 ELF_SET_FIELD (type_functions
, ei_class
, Shdr
,
1402 shdr
, sh_flags
, Elf_Addr
, flags
);
1407 XDELETEVEC (pfnret
);
1408 XDELETEVEC (pfnname
);
1414 /* The ELF functions. */
1416 const struct simple_object_functions simple_object_elf_functions
=
1418 simple_object_elf_match
,
1419 simple_object_elf_find_sections
,
1420 simple_object_elf_fetch_attributes
,
1421 simple_object_elf_release_read
,
1422 simple_object_elf_attributes_merge
,
1423 simple_object_elf_release_attributes
,
1424 simple_object_elf_start_write
,
1425 simple_object_elf_write_to_file
,
1426 simple_object_elf_release_write
,
1427 simple_object_elf_copy_lto_debug_sections