[Bug libelf/32232] New: Failed tests with lld linker
https://sourceware.org/bugzilla/show_bug.cgi?id=32232 Bug ID: 32232 Summary: Failed tests with lld linker Product: elfutils Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: libelf Assignee: unassigned at sourceware dot org Reporter: raj.khem at gmail dot com CC: elfutils-devel at sourceware dot org Target Milestone: --- Created attachment 15726 --> https://sourceware.org/bugzilla/attachment.cgi?id=15726&action=edit test run log When I try to build elfutils with CC=clang LDFLAGS=-fuse-ld=lld ./configure --enable-maintainer-mode 6 tests end in failures. Attached are the log. They work ok if I remove -fuse-ld=lld or use -fuse-ld=bfd in LDFLAGS -- You are receiving this mail because: You are on the CC list for the bug.
[PATCH] tests: Fix specifying constant of double type
'd' suffix seems to be not acceptable by clang compiler Using 'e0' fixes this by keeping value to be same Fixes funcretval_test_struct.c:83:27: error: invalid suffix 'd' on floating constant 83 | dpoint_t dp = dmkpt (3.0d, 1.0d); | ^ funcretval_test_struct.c:83:33: error: invalid suffix 'd' on floating constant 83 | dpoint_t dp = dmkpt (3.0d, 1.0d); | Signed-off-by: Khem Raj --- tests/funcretval_test_struct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/funcretval_test_struct.c b/tests/funcretval_test_struct.c index df94bde0..6bf82f7d 100644 --- a/tests/funcretval_test_struct.c +++ b/tests/funcretval_test_struct.c @@ -80,7 +80,7 @@ main (void) div_t d = div (3, 2); ldiv_t ld = ldiv (3, 2); point_t p = mkpt (3.0f, 1.0f); - dpoint_t dp = dmkpt (3.0d, 1.0d); + dpoint_t dp = dmkpt (3.0e0, 1.0e0); return d.q - (int) p.y + ld.q - (int) dp.y; }
[PATCH 2/9 v2] doc: Add elf32_fsize.3 and elf64_fsize.3
Signed-off-by: Aaron Merey --- v2 changes: Reword description. State EV_CURRENT is the only valid version. Mention possibility of integer overflow. On Tue, Aug 27, 2024 at 12:32 PM Mark Wielaard wrote: > > Maybe give at least some examples of Elf_Type and which data structure > they represent? ELF_T_ADDR (32 bit address), ELF_T_EHDR (Elf32_Ehdr), > etc. > > And mention that elf_getdata will set the Elf_Data d_type to the > Elf_Type of the section? I added "See libelf(3) for more information regarding Elf_Type" to the description. This man page doesn't exist yet but I will add it and include a list of the different Elf_Type and its relationship to Elf_Data. doc/elf32_fsize.3 | 78 +++ doc/elf64_fsize.3 | 1 + 2 files changed, 79 insertions(+) create mode 100644 doc/elf32_fsize.3 create mode 100644 doc/elf64_fsize.3 diff --git a/doc/elf32_fsize.3 b/doc/elf32_fsize.3 new file mode 100644 index ..a0aac70e --- /dev/null +++ b/doc/elf32_fsize.3 @@ -0,0 +1,78 @@ +.TH ELF32_FSIZE 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_fsize, elf64_fsize \- calculate the file size of an ELF data structure + +.SH SYNOPSIS +.nf +.B #include + +.BI "size_t elf32_fsize(Elf_Type " type ", size_t " count ", unsigned int " version ");" +.BI "size_t elf64_fsize(Elf_Type " type ", size_t " count ", unsigned int " version ");" + +.SH DESCRIPTION +Given an +.B Elf_Type +representation of a core ELF structure as well as the number of items, return +the number of bytes needed for the on-disk representation in a 32-bit or 64-bit +ELF file. The on-disk and in-memory representations of +.B Elf_Type +are assumed to be the same. See +.BR libelf (3) +for more information regarding +.BR Elf_Type . + +.SH PARAMETERS +.TP +.I type +The ELF data structure type for which the file size is to be calculated. + +.TP +.I count +The number of elements of the specified type. + +.TP +.I version +The ELF version. This should be set to +.BR EV_CURRENT , +which is the only valid value. + +.SH RETURN VALUE +The size in bytes of the specified count and type of data structure. +If version is not set to +.B EV_CURRENT +or +.I type +is not a valid +.BR Elf_Type , +return 0 and set a libelf error code. Integer overflow can occur if +the size of +.I type +multiplied by +.I count +is greater than +.BR SIZE_MAX . + +.SH SEE ALSO +.BR elf_errno (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_fsize (), +.BR elf64_fsize () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_fsize.3 b/doc/elf64_fsize.3 new file mode 100644 index ..178152ec --- /dev/null +++ b/doc/elf64_fsize.3 @@ -0,0 +1 @@ +.so man3/elf32_fsize.3 -- 2.46.2
[PATCH 1/9 v2] doc: Add elf32_checksum.3 and elf64_checksum.3
Signed-off-by: Aaron Merey --- v2 changes: elf64_checksum.3 now refers to elf32_checksum.3. Explained which sections are used to calculate the checksum. Mentioned DT_CHECKSUM. Mentioned that the checksum is a 4-byte value that might be zero-extended. doc/elf32_checksum.3 | 60 doc/elf64_checksum.3 | 1 + 2 files changed, 61 insertions(+) create mode 100644 doc/elf32_checksum.3 create mode 100644 doc/elf64_checksum.3 diff --git a/doc/elf32_checksum.3 b/doc/elf32_checksum.3 new file mode 100644 index ..ab707f15 --- /dev/null +++ b/doc/elf32_checksum.3 @@ -0,0 +1,60 @@ +.TH ELF32_CHECKSUM 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_checksum, elf64_checksum \- compute the checksum for a 32-bit or 64-bit +ELF object file + +.SH SYNOPSIS +.nf +.B #include + +.BI "long int elf32_checksum(Elf *" elf ");" +.BI "long int elf64_checksum(Elf *" elf ");" + +.SH DESCRIPTION +Compute a checksum for the ELF object file referred to by +.IR elf . +The checksum is computed from permanent parts of the ELF file and +the result is repeatable. To be repeatable, strippable sections are +not included in computing the checksum. +.B SHT_NOBITS +sections are also not included when computing the checksum. The checksum +can be used as a value for +.BR DT_CHECKSUM . + +.SH PARAMETERS +.TP +.I elf +The ELF object file for which the checksum is to be computed. + +.SH RETURN VALUE +On success, return the computed checksum. If an error occurs, return -1 +and set a libelf error code. The checksum is always calculated a 4-byte +value. If +.I long int +is larger than 4 bytes, then the checksum will be extended by padding +with zeros. + +.SH SEE ALSO +.BR elf_errno (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_checksum (), +.BR elf64_checksum () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_checksum.3 b/doc/elf64_checksum.3 new file mode 100644 index ..16d3cc24 --- /dev/null +++ b/doc/elf64_checksum.3 @@ -0,0 +1 @@ +.so man3/elf32_checksum.3 -- 2.46.2
[PATCH 7/9 v2] doc: Add elf32_newphdr.3 and elf64_newphdr.3
Signed-off-by: Aaron Merey --- v2 changes: Mention new program header table is zero'ed out and that NULL is returned if elf is NULL. doc/elf32_newphdr.3 | 72 + doc/elf64_newphdr.3 | 1 + 2 files changed, 73 insertions(+) create mode 100644 doc/elf32_newphdr.3 create mode 100644 doc/elf64_newphdr.3 diff --git a/doc/elf32_newphdr.3 b/doc/elf32_newphdr.3 new file mode 100644 index ..9b3ddc91 --- /dev/null +++ b/doc/elf32_newphdr.3 @@ -0,0 +1,72 @@ +.TH ELF32_NEWPHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_newphdr, elf64_newphdr \- create a new program header table for a +32-bit or 64-bit ELF object file + +.SH SYNOPSIS +.nf +.B #include + +.BI "Elf32_Phdr *elf32_newphdr(Elf *" elf ", size_t " count ");" +.BI "Elf64_Phdr *elf64_newphdr(Elf *" elf ", size_t " count ");" + +.SH DESCRIPTION +Create a new program header table for the ELF object file referred to by +.IR elf . +The number of entries in the new program header table is specified by +.IR count . +A +.I count +of zero removes the existing program header table. + +The function allocates a new array of +.B Elf32_Phdr +and makes it the program header table for +.IR elf . +The new program header contents are set to zero and any previous program +header table is discarded. An ELF header must exist before creating a +program header table. + +.SH PARAMETERS +.TP +.I elf +Pointer to the ELF object for which a new program header table is to be created. + +.TP +.I count +The number of entries in the new program header table. A count of zero removes +the existing program header table. + +.SH RETURN VALUE +On success, return a pointer to the first +.B Elf32_Phdr +in the newly created program header table. If +.I elf +is NULL then return NULL. If an error occurs, return NULL and set a libelf +error code. + +.SH SEE ALSO +.BR elf32_newehdr (3), +.BR elf_errno (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_newphdr (), +.BR elf64_newphdr () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_newphdr.3 b/doc/elf64_newphdr.3 new file mode 100644 index ..86e8ed3c --- /dev/null +++ b/doc/elf64_newphdr.3 @@ -0,0 +1 @@ +.so man3/elf32_newphdr.3 -- 2.46.2
[PATCH 3/9 v2] doc: Add elf32_getchdr.3 and elf64_getchdr.3
Signed-off-by: Aaron Merey --- v2 changes: Mention that SHF_COMPRESSED must be set. Add elf_compress (3) to SEE ALSO. Remove "This elfutils libelf function may not be found in other libelf implementations". On Tue, Aug 27, 2024 at 1:23 PM Mark Wielaard wrote: > > It should also mention what the Elf32_Chdr structure looks > like and what the meaning the fields have. What the legal values of > ch_type are, that ch_size is the uncompressed section data size, and > that ch_addralign is the alignment of the uncompressed data. I will include this information in the upcoming libelf man page. doc/elf32_getchdr.3 | 60 + doc/elf64_getchdr.3 | 1 + 2 files changed, 61 insertions(+) create mode 100644 doc/elf32_getchdr.3 create mode 100644 doc/elf64_getchdr.3 diff --git a/doc/elf32_getchdr.3 b/doc/elf32_getchdr.3 new file mode 100644 index ..f7f35c96 --- /dev/null +++ b/doc/elf32_getchdr.3 @@ -0,0 +1,60 @@ +.TH ELF32_GETCHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_getchdr, elf64_getchdr \- retrieve the compression header for a +section from a 32-bit or 64-bit ELF object file. + +.SH SYNOPSIS +.nf +.B #include + +.BI "Elf32_Chdr *elf32_getchdr(Elf_Scn *" scn ");" +.BI "Elf64_Chdr *elf64_getchdr(Elf_Scn *" scn ");" + +.SH DESCRIPTION +Retrieve the compression header for a section with compressed data. +Sections with compressed data are indicated with the +.B SHF_COMPRESSED +flag. See +.BR libelf (3) +for more information regarding the compression header. + +.SH PARAMETERS +.TP +.I scn +Section whose compression header will be retrieved. The section's +.B SHF_COMPRESSED +flag must be set. + +.SH RETURN VALUE +On success, return a pointer to the compression header. On failure, +return NULL and set a libelf error code. + +.SH SEE ALSO +.BR elf_compress (3), +.BR elf_errno (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_getchdr (), +.BR elf64_getchdr () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. + +.SH HISTORY +.B elf32_getchdr +first appeared in elfutils 0.165. diff --git a/doc/elf64_getchdr.3 b/doc/elf64_getchdr.3 new file mode 100644 index ..fa49616b --- /dev/null +++ b/doc/elf64_getchdr.3 @@ -0,0 +1 @@ +.so man3/elf32_getchdr.3 -- 2.46.2
[PATCH 8/9 v2] doc: Add elf{32, 64}_xlatetof.3 and elf{32, 64}_xlatetom.3
Signed-off-by: Aaron Merey --- v2 changes: Merge xlatetof and xlatetom man pages. Added additional details suggested in Mark's review https://sourceware.org/pipermail/elfutils-devel/2024q3/007377.html doc/elf32_xlatetof.3 | 1 + doc/elf32_xlatetom.3 | 130 +++ doc/elf64_xlatetof.3 | 1 + doc/elf64_xlatetom.3 | 1 + 4 files changed, 133 insertions(+) create mode 100644 doc/elf32_xlatetof.3 create mode 100644 doc/elf32_xlatetom.3 create mode 100644 doc/elf64_xlatetof.3 create mode 100644 doc/elf64_xlatetom.3 diff --git a/doc/elf32_xlatetof.3 b/doc/elf32_xlatetof.3 new file mode 100644 index ..47ecda27 --- /dev/null +++ b/doc/elf32_xlatetof.3 @@ -0,0 +1 @@ +.so man3/elf32_xlatetom.3 diff --git a/doc/elf32_xlatetom.3 b/doc/elf32_xlatetom.3 new file mode 100644 index ..ec2024fd --- /dev/null +++ b/doc/elf32_xlatetom.3 @@ -0,0 +1,130 @@ +.TH ELF32_XLATETOM 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +.nf +elf32_xlatetom, elf64_xlatetom \- translate 32-bit or 64-bit ELF data from file +representation to memory representation + +elf32_xlatetof, elf64_xlatetof \- translate 32-bit or 64-bit ELF data from memory +representation to file representation + +.SH SYNOPSIS +.nf +.B #include + +.BI "int elf32_xlatetom(Elf_Data *" dst ", const Elf_Data *" src ", unsigned int " encoding ");" +.BI "int elf64_xlatetom(Elf_Data *" dst ", const Elf_Data *" src ", unsigned int " encoding ");" + +.BI "int elf32_xlatetof(Elf_Data *" dst ", const Elf_Data *" src ", unsigned int " encoding ");" +.BI "int elf64_xlatetof(Elf_Data *" dst ", const Elf_Data *" src ", unsigned int " encoding ");" + +.SH DESCRIPTION +Translate ELF data from file representation to memory representation or +vice versa. File and memory representations of ELF data can differ in +terms of endianness. Data in file representation normally comes from +.B elf_rawdata +while data in memory representation normally comes from +.BR elf_getdata . +When there is no difference between file and memory representations, +these functions simply copy the ELF data from +.I src +to +.IR dst . +Otherwise the encoding with swap between +.B ELFDATA2LSB +(two's complement little-endian) and +.B ELFDATA2MSB +(two's complement big-endian). The encoding of an ELF file is specified +in the +.B Elf32_Ehdr +or +.B Elf64_Ehdr e_ident[EI_DATA] +member. To know the memory encoding for a program you can +.B #include +and check BYTE_ORDER == LITTLE_ENDIAN (corresponding to +.BR ELFDATA2LSB ) +or BYTE_ORDER == BIG_ENDIAN (corresponding to +.BR ELFDATA2MSB ). + +.SH PARAMETERS +.TP +.I dst +Destination where the translated data will be stored. +The +.B d_size +of +.I dst +should be at least as big as the +.B d_size +of +.IR src . + +.TP +.I src +Source data. For the +.B xlatetom +functions, the source data should be in file representation. +For the +.B xlatetof +functions, the source data should be in memory representation. + +.TP +.I encoding +Specifies an encoding. Can be either +.B ELFDATA2LSB +(two's complement little-endian) or +.B ELFDATA2MSB +(two's complement big-endian). For the +.B xlatetom +functions, this specifies the encoding of +.IR src . +For the +.B xlatetof +functions, this specifies the encoding of +.IR dst . + +.SH RETURN VALUE +On success, return +.IR dst , +which will contain the translated data. If there is no difference +between the file and memory representations, +.I dst +will contain a copy of the source data. The +.B d_type +and +.B d_size +of +.I dst +will be set to those of +.IR src . + + If an error occurs, return +NULL and set a libelf error code. + +.SH SEE ALSO +.BR elf_errno (3), +.BR elf_getdata (3), +.BR elf_rawdata (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_xlatetom (), +.BR elf64_xlatetom (), +.BR elf32_xlatetof (), +.BR elf64_xlatetof () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_xlatetof.3 b/doc/elf64_xlatetof.3 new file mode 100644 index ..47ecda27 --- /dev/null +++ b/doc/elf64_xlatetof.3 @@ -0,0 +1 @@ +.so man3/elf32_xlatetom.3 diff --git a/doc/elf64_xlatetom.3 b/doc/elf64_xlatetom.3 new file mode 100644 index ..47ecda27 --- /dev/null +++ b/doc/elf64_xlatetom.3 @@ -0,0 +1 @@ +.so man3/elf32_xlatetom.3 -- 2.46.2
[PATCH 9/9] doc/Makefile.am: Add man pages
Add the following man pages to notrans_dist_man3_MANS: elf32_xlatetom.3 elf64_xlatetom.3 elf32_xlatetof.3 elf64_xlatetof.3 elf32_newphdr.3 elf64_newphdr.3 elf32_newehdr.3 elf64_newehdr.3 elf32_getshdr.3 elf64_getshdr.3 elf32_getphdr.3 elf64_getphdr.3 elf32_getchdr.3 elf64_getchdr.3 elf32_fsize.3 elf64_fsize.3 elf32_checksum.3 elf64_checksum.3 Signed-off-by: Aaron Merey --- doc/Makefile.am | 20 +++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/doc/Makefile.am b/doc/Makefile.am index 86c1d82d..ceb6fd2d 100644 --- a/doc/Makefile.am +++ b/doc/Makefile.am @@ -39,7 +39,25 @@ notrans_dist_man3_MANS= elf_update.3 \ elf32_offscn.3 \ elf64_offscn.3 \ elf_getscn.3 \ - elf_ndxscn.3 + elf_ndxscn.3 \ + elf32_xlatetom.3 \ + elf64_xlatetom.3 \ + elf32_xlatetof.3 \ + elf64_xlatetof.3 \ + elf32_newphdr.3 \ + elf64_newphdr.3 \ + elf32_newehdr.3 \ + elf64_newehdr.3 \ + elf32_getshdr.3 \ + elf64_getshdr.3 \ + elf32_getphdr.3 \ + elf64_getphdr.3 \ + elf32_getchdr.3 \ + elf64_getchdr.3 \ + elf32_fsize.3 \ + elf64_fsize.3 \ + elf32_checksum.3 \ + elf64_checksum.3 # libdebuginfod man pages (also notrans) # Note we include them even when not building them because we want -- 2.46.2
[PATCH 5/9 v2] doc: Add elf32_getshdr.3 and elf64_getshdr.3
Signed-off-by: Aaron Merey --- v2 changes: Mention elf_flagshdr. Mention NULL is returned if scn is NULL. doc/elf32_getshdr.3 | 59 + doc/elf64_getshdr.3 | 1 + 2 files changed, 60 insertions(+) create mode 100644 doc/elf32_getshdr.3 create mode 100644 doc/elf64_getshdr.3 diff --git a/doc/elf32_getshdr.3 b/doc/elf32_getshdr.3 new file mode 100644 index ..abc8aaeb --- /dev/null +++ b/doc/elf32_getshdr.3 @@ -0,0 +1,59 @@ +.TH ELF32_GETSHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_getshdr, elf64_getshdr \- retrieve the section header for a section +in 32-bit or 64-bit ELF object file + +.SH SYNOPSIS +.nf +.B #include + +.BI "Elf32_Shdr *elf32_getshdr(Elf_Scn *" scn ");" +.BI "Elf64_Shdr *elf64_getshdr(Elf_Scn *" scn ");" + +.SH DESCRIPTION +Retrieve the section header for the section referred to by +.IR scn . +If the retrieved section header is modified, +.B elf_flagshdr +must be called +with +.B ELF_C_SET +and +.B ELF_F_DIRTY +in order to write the modified section header to disk. + +.SH PARAMETERS +.TP +.I scn +The section descriptor whose section header is to be retrieved. + +.SH RETURN VALUE +On success, return a pointer to the section header. If scn is NULL then +NULL will be returned. If an error occurs, return NULL and set a libelf +error code. + +.SH SEE ALSO +.BR elf_errno (3), +.BR elf_flagshdr (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_getshdr (), +.BR elf64_getshdr () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_getshdr.3 b/doc/elf64_getshdr.3 new file mode 100644 index ..c0d2410c --- /dev/null +++ b/doc/elf64_getshdr.3 @@ -0,0 +1 @@ +.so man3/elf32_getshdr.3 -- 2.46.2
[PATCH 4/9 v2] doc: Add elf32_getphdr.3 and elf64_getphdr.3
Signed-off-by: Aaron Merey --- v2 changes: Improved description. Mention that NULL is returned if there is no program header. Add elf_getphdrnum and elf32_newphdr to SEE ALSO. doc/elf32_getphdr.3 | 66 + doc/elf64_getphdr.3 | 1 + 2 files changed, 67 insertions(+) create mode 100644 doc/elf32_getphdr.3 create mode 100644 doc/elf64_getphdr.3 diff --git a/doc/elf32_getphdr.3 b/doc/elf32_getphdr.3 new file mode 100644 index ..5e9fe2dd --- /dev/null +++ b/doc/elf32_getphdr.3 @@ -0,0 +1,66 @@ +.TH ELF32_GETPHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_getphdr, elf64_getphdr \- retrieve the program header table for a +32-bit or 64-bit ELF object file + +.SH SYNOPSIS +.nf +.B #include + +.BI "Elf32_Phdr *elf32_getphdr(Elf *" elf ");" +.BI "Elf64_Phdr *elf64_getphdr(Elf *" elf ");" + +.SH DESCRIPTION +Retrieve the program header table for the given ELF descriptor +.IR elf . +The number of elements in the program header table can be retrieved with +.B elf32_getphdrnum +and +.BR elf64_getphdrnum . +.B elf32_newphdr +and +.B elf64_newphdr +change the size of the program header table or to delete it. +If changing an element of the program header table, you must +call elf_flagphdr with +.B ELF_C_SET +and +.B ELF_F_DIRTY +in order to write the new data to disk. + +.SH PARAMETERS +.TP +.I elf +ELF descriptor from which to retrieve the program header table. + +.SH RETURN VALUE +On success, return a pointer to the program header table. Return NULL if +there is no program header. On failure, return NULL and set a libelf +error code. + +.SH SEE ALSO +.BR elf32_newphdr (3), +.BR elf_errno (3), +.BR elf_getphdrnum (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_getphdr (), +.BR elf64_getphdr () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_getphdr.3 b/doc/elf64_getphdr.3 new file mode 100644 index ..3301d1e9 --- /dev/null +++ b/doc/elf64_getphdr.3 @@ -0,0 +1 @@ +.so man3/elf32_getphdr.3 -- 2.46.2
[PATCH 6/9 v2] doc: Add elf32_newehdr.3 and elf64_newehdr.3
Signed-off-by: Aaron Merey --- v2 changes: Mention that the existing header will be returned if one is already present. Mention that an ELF header must be present before callling elf_newscn or elf_newphdr doc/elf32_newehdr.3 | 60 + doc/elf64_newehdr.3 | 1 + 2 files changed, 61 insertions(+) create mode 100644 doc/elf32_newehdr.3 create mode 100644 doc/elf64_newehdr.3 diff --git a/doc/elf32_newehdr.3 b/doc/elf32_newehdr.3 new file mode 100644 index ..d5d34547 --- /dev/null +++ b/doc/elf32_newehdr.3 @@ -0,0 +1,60 @@ +.TH ELF32_NEWEHDR 3 2024-08-14 "Libelf" "Libelf Programmer's Manual" + +.SH NAME +elf32_newehdr, elf64_newehdr \- create a new ELF header for a 32-bit or +64-bit ELF object file + +.SH SYNOPSIS +.nf +.B #include + +.BI "Elf32_Ehdr *elf32_newehdr(Elf *" elf ");" +.BI "Elf64_Ehdr *elf64_newehdr(Elf *" elf ");" + +.SH DESCRIPTION +This function initializes a new ELF header and associates it with +.IR elf . +If +.I elf +already has an ELF header associated with it, no new header will be created +and the existing header will be returned. An ELF header must be present +before calling +.B elf_newscn +or +.BR elf_newphdr . + +.SH PARAMETERS +.TP +.I elf +ELF descriptor for which a new ELF header is to be created. + +.SH RETURN VALUE +On success, return a pointer to the newly created ELF header. If +.I elf +already has an ELF header associated with it, this pre-existing header is +returned and no new header is created. On failure, return NULL and set a +libelf error code. + +.SH SEE ALSO +.BR elf_errno (3), +.BR libelf (3), +.BR elf (5) + +.SH ATTRIBUTES +For an explanation of the terms used in this section, see +.BR attributes (7). +.TS +allbox; +lbx lb lb +l l l. +Interface Attribute Value +T{ +.na +.nh +.BR elf32_newehdr (), +.BR elf64_newehdr () +T} Thread safety MT-Safe +.TE + +.SH REPORTING BUGS +Report bugs to or https://sourceware.org/bugzilla/. diff --git a/doc/elf64_newehdr.3 b/doc/elf64_newehdr.3 new file mode 100644 index ..9119d838 --- /dev/null +++ b/doc/elf64_newehdr.3 @@ -0,0 +1 @@ +.so man3/elf32_newehdr.3 -- 2.46.2