☺ Buildbot (Sourceware): elfutils - build successful (main)

2025-09-15 Thread builder
A restored build has been detected on builder elfutils-debian-armhf while 
building elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#/builders/6/builds/439

Build state: build successful
Revision: 13153e98ee4f4b4ad2c73c2a747b6c2db984e029
Worker: debian-armhf
Build Reason: (unknown)
Blamelist: Aaron Merey , Mark Wielaard 

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/4/logs/stdio
- config.log: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/4/logs/config_log

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/6/logs/warnings__3_

- 7: make check ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/7/logs/test-suite_log

- 8: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/8/logs/stdio

- 9: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/9/logs/stdio

- 10: fetch bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/10/logs/stdio

- 11: unpack bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/11/logs/stdio

- 12: pass .bunsen.source.* ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/12/logs/stdio

- 13: upload to bunsen ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/13/logs/stdio

- 14: clean up ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/14/logs/stdio

- 15: make distclean ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/6/builds/439/steps/15/logs/stdio

A new failure has been detected on builder elfutils-fedora-ppc64le while 
building elfutils.

Full details are available at:
https://builder.sourceware.org/buildbot/#/builders/55/builds/436

Build state: failed test (failure)
Revision: 13153e98ee4f4b4ad2c73c2a747b6c2db984e029
Worker: fedora-ppc64le
Build Reason: (unknown)
Blamelist: Mark Wielaard 

Steps:

- 0: worker_preparation ( success )

- 1: set package name ( success )

- 2: git checkout ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/2/logs/stdio

- 3: autoreconf ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/3/logs/stdio

- 4: configure ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/4/logs/stdio
- config.log: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/4/logs/config_log

- 5: get version ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/5/logs/stdio
- property changes: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/5/logs/property_changes

- 6: make ( warnings )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/6/logs/stdio
- warnings (3): 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/6/logs/warnings__3_

- 7: make check ( failure )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/7/logs/stdio
- test-suite.log: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/7/logs/test-suite_log

- 8: prep ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/8/logs/stdio

- 9: build bunsen.cpio.gz ( success )
Logs:
- stdio: 
https://builder.sourceware.org/buildbot/#/builders/55/builds/436/steps/9/logs/stdio

- 10: fetch bunsen.cpio.gz ( success )
 

[COMMITTED] libelf: check ehdr isn't NULL before calling default_ehdr

2025-09-15 Thread Mark Wielaard
default_ehdr assumes the passed ehdr pointer is not NULL and can be
directly dereferenced. But getehdr can return NULL. So explicitly
check.

* libelf/elf32_updatenull.c (updatenull_wrlock): Check ehdr is
not NULL.

https://sourceware.org/bugzilla/show_bug.cgi?id=33433

Signed-off-by: Mark Wielaard 
---
 libelf/elf32_updatenull.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/libelf/elf32_updatenull.c b/libelf/elf32_updatenull.c
index 3594e8bad6c0..74c27fdaa7b5 100644
--- a/libelf/elf32_updatenull.c
+++ b/libelf/elf32_updatenull.c
@@ -135,7 +135,8 @@ __elfw2(LIBELFBITS,updatenull_wrlock) (Elf *elf, int 
*change_bop, size_t shnum)
   ehdr = __elfw2(LIBELFBITS,getehdr_wrlock) (elf);
 
   /* Set the default values.  */
-  if (ELFW(default_ehdr,LIBELFBITS) (elf, ehdr, shnum, change_bop) != 0)
+  if (ehdr == NULL
+  || ELFW(default_ehdr,LIBELFBITS) (elf, ehdr, shnum, change_bop) != 0)
 return -1;
 
   /* At least the ELF header is there.  */
-- 
2.51.0



Re: [PATCH 1/4 v3] doc: Add elf_flag*.3

2025-09-15 Thread Mark Wielaard
Hi Aaron,

One small comment below, but this looks good with or without that.

On Sun, Sep 14, 2025 at 07:20:59PM -0400, Aaron Merey wrote:
> v3 changes:
> Fix unbalanced " in SYNOPSIS.
> Reword ELF_F_LAYOUT description and mention that phdr offset changes will
> prevent automatic changes to shdr offset changes during elf_update.
> Mention that ELF_F_PERMISSIVE is an elfutils extention.
> 
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index 8d799643..8154 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -56,6 +56,12 @@ notrans_dist_man3_MANS= elf32_checksum.3 \
>   elf_errmsg.3 \
>   elf_errno.3 \
>   elf_fill.3 \
> + elf_flagelf.3 \
> + elf_flagehdr.3 \
> + elf_flagphdr.3 \
> + elf_flagscn.3 \
> + elf_flagdata.3 \
> + elf_flagshdr.3 \
>   elf_getarhdr.3 \
>   elf_getaroff.3 \
>   elf_getarsym.3 \

OK


> diff --git a/doc/elf_flagdata.3 b/doc/elf_flagdata.3
> new file mode 100644
> index ..ee84d431
> --- /dev/null
> +++ b/doc/elf_flagdata.3
> @@ -0,0 +1 @@
> +.so man3/elf_flagelf.3
> diff --git a/doc/elf_flagehdr.3 b/doc/elf_flagehdr.3
> new file mode 100644
> index ..ee84d431
> --- /dev/null
> +++ b/doc/elf_flagehdr.3
> @@ -0,0 +1 @@
> +.so man3/elf_flagelf.3

OK.

> diff --git a/doc/elf_flagelf.3 b/doc/elf_flagelf.3
> new file mode 100644
> index ..0a8482f2
> --- /dev/null
> +++ b/doc/elf_flagelf.3
> @@ -0,0 +1,184 @@
> +.TH ELF_FLAGELF 3 2025-06-23 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +elf_flagelf, elf_flagdata, elf_flagehdr, elf_flagphdr, elf_flagscn, 
> elf_flagshdr \- set or clear flags on ELF descriptors and components
> +.SH SYNOPSIS
> +.nf
> +.B #include 
> +
> +.BI "unsigned int elf_flagelf(Elf * " elf ", Elf_Cmd " cmd ", unsigned int " 
> flags ");"
> +.BI "unsigned int elf_flagehdr(Elf * " elf ", Elf_Cmd " cmd ", unsigned int 
> " flags ");"
> +.BI "unsigned int elf_flagphdr(Elf * " elf ", Elf_Cmd " cmd ", unsigned int 
> " flags ");"
> +.BI "unsigned int elf_flagscn(Elf_Scn * " scn ", Elf_Cmd " cmd ", unsigned 
> int " flags ");"
> +.BI "unsigned int elf_flagshdr(Elf_Scn * " scn ", Elf_Cmd " cmd ", unsigned 
> int " flags ");"
> +.BI "unsigned int elf_flagdata(Elf_Data * " data ", Elf_Cmd " cmd ", 
> unsigned int " flags ");"
> +.fi

OK.

> +
> +.SH DESCRIPTION
> +These functions allow the caller to set or clear flags on various ELF
> +components managed by
> +.B libelf .
> +They are typically used to indicate that a component has been modified
> +(dirty), or to control layout behavior during output.

OK.

> +.BR elf_flagelf ()
> +modifies flags on the top-level
> +.B Elf
> +descriptor.
> +
> +.BR elf_flagdata ()
> +modifies flags on an
> +.B Elf_Data
> +descriptor, typically retrieved using
> +.BR elf_getdata (3)
> +or created with
> +.BR elf_newdata (3).
> +
> +.BR elf_flagehdr ()
> +modifies flags on the ELF header for a ELF descriptor (e.g., the result of
> +.BR gelf_getehdr (3)).
> +
> +.BR elf_flagphdr ()
> +modifies flags on the program header table of an ELF descriptor.
> +
> +.BR elf_flagscn ()
> +modifies flags on an
> +.B Elf_Scn
> +(section) descriptor.
> +
> +.BR elf_flagshdr ()
> +modifies flags on the section header of a given
> +.B Elf_Scn .
> +

OK.

> +The
> +.I cmd
> +argument determines whether the given flags should be set (
> +.B ELF_C_SET
> +) or cleared (
> +.B ELF_C_CLR
> +).

OK.

> +The following flag values may be passed via the
> +.I flags
> +parameter:
> +
> +.TP
> +.B ELF_F_DIRTY
> +Marks the object as modified. This ensures changes to the component is 
> written
> +out during
> +.BR elf_update (3).
> +
> +.TP
> +.B ELF_F_LAYOUT
> +Indicates that the layout of the ELF component is managed manually. Offsets 
> and
> +sizes will be preserved as provided.  This flag is only used with
> +.BR elf_flagelf ()
> +and is ignored when used with other functions.
> +If this flag is set the user must set Ehdr
> +.IR e_phoff ,
> +.IR e_shoff ,
> +as well as
> +.B Elf_Data
> +.I d_off
> +and Shdr
> +.IR sh_offset .
> +If not set, then these offsets will be recalculated when
> +.B elf_update
> +is called.
> +If
> +.B ELF_F_LAYOUT
> +is set then changes to phdr offsets will prevent elf_update from 
> automatically
> +adjusting shdr offsets.

OK.

> +.TP
> +.B ELF_F_PERMISSIVE
> +Enables relaxed validation of object structure. This flag permits nonstandard
> +layouts without strict checks.  Specifically this removes a check in
> +.BR elf_update ()
> +that the section
> +.I sh_size
> +is a multiple of the section
> +.I sh_entsize
> +(if not zero).  This flag is only used with
> +.BR elf_flagelf ()
> +and is ignored when used with other functions.
> +.B ELF_F_PERMISSIVE
> +is an elfutils libelf extention and may not be available in other libelf
> +implementations.

OK.

> +.SH PARAMETE

[Bug libelf/33433] New: elf32_updatenull.c:57:7: error: potential null pointer dereference [-Werror=null-dereference]

2025-09-15 Thread sch...@linux-m68k.org
https://sourceware.org/bugzilla/show_bug.cgi?id=33433

Bug ID: 33433
   Summary: elf32_updatenull.c:57:7: error: potential null pointer
dereference [-Werror=null-dereference]
   Product: elfutils
   Version: unspecified
Status: NEW
  Severity: normal
  Priority: P2
 Component: libelf
  Assignee: unassigned at sourceware dot org
  Reporter: sch...@linux-m68k.org
CC: elfutils-devel at sourceware dot org
  Target Milestone: ---

When building with current gcc trunk libelf.so fails to build with LTO:

gcc -Wall -Wshadow -Wformat=2 -Wold-style-definition -Wstrict-prototypes
-Wtrampolines -Wlogical-op -Wduplicated-cond -Wnull-dereference
-Wimplicit-fallthrough=5 -Wuse-after-free=3 -Werror -Wunused -Wextra
-Wstack-usage=262144-O2 -Wall -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3
-fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables
-fstack-clash-protection -Werror=return-type -flto=auto -ffat-lto-objects -g -g
-Werror=date-time  -flto=auto -ffat-lto-objects -o libelf.so -shared
-Wl,-z,defs -Wl,-z,relro -o libelf.so \
-Wl,--soname,libelf.so.1 \
-Wl,--version-script,libelf.map \
-Wl,--no-undefined \
-Wl,--whole-archive libelf_pic.a -Wl,--no-whole-archive \
../lib/libeu.a -lz -lzstd -llzma  -lbz2  
In function ‘default_ehdr64’,
inlined from ‘__elf64_updatenull_wrlock’ at elf32_updatenull.c:138:7,
inlined from ‘elf_update’ at elf_update.c:211:6:
elf32_updatenull.c:57:7: error: potential null pointer dereference
[-Werror=null-dereference]
   57 |   if (memcmp (&ehdr->e_ident[EI_MAG0], ELFMAG, SELFMAG) != 0)
  |   ^
lto1: all warnings being treated as errors
make[3]: *** [/tmp/ccENG5L0.mk:2: /tmp/ccMoFZZ9.ltrans0.ltrans.o] Error 1
lto-wrapper: fatal error: make returned 2 exit status
compilation terminated.
/usr/lib64/gcc/x86_64-suse-linux/16/../../../../x86_64-suse-linux/bin/ld:
error: lto-wrapper failed
collect2: error: ld returned 1 exit status
make[2]: *** [Makefile:1395: libelf.so] Error 1
make[1]: *** [Makefile:626: all-recursive] Error 1
make: *** [Makefile:541: all] Error 2

Since getehdr_wrlock can return NULL, this seems to be a valid complaint.

-- 
You are receiving this mail because:
You are on the CC list for the bug.

Re: [PATCH 2/4 v3] doc: Add elf_memory.3

2025-09-15 Thread Mark Wielaard
Hi Aaron,

On Sun, Sep 14, 2025 at 07:21:00PM -0400, Aaron Merey wrote:
> Signed-off-by: Aaron Merey 
> 
> ---
> v3: Mention that the underlying memory image should be writable since
> libelf may attempt to modify it.  Remove some implementation details.
> 
>  doc/Makefile.am  |  1 +
>  doc/elf_memory.3 | 85 
>  2 files changed, 86 insertions(+)
>  create mode 100644 doc/elf_memory.3
> 
> diff --git a/doc/Makefile.am b/doc/Makefile.am
> index 8154..96d35d20 100644
> --- a/doc/Makefile.am
> +++ b/doc/Makefile.am
> @@ -78,6 +78,7 @@ notrans_dist_man3_MANS= elf32_checksum.3 \
>   elf_hash.3 \
>   elf_gnu_hash.3 \
>   elf_kind.3 \
> + elf_memory.3 \
>   elf_ndxscn.3 \
>   elf_newdata.3 \
>   elf_newscn.3 \

OK.

> diff --git a/doc/elf_memory.3 b/doc/elf_memory.3
> new file mode 100644
> index ..8f4efced
> --- /dev/null
> +++ b/doc/elf_memory.3
> @@ -0,0 +1,85 @@
> +.TH ELF_MEMORY 3 2025-06-23 "Libelf" "Libelf Programmer's Manual"
> +
> +.SH NAME
> +elf_memory \- create an ELF descriptor from a memory buffer
> +.SH SYNOPSIS
> +.nf
> +#include 
> +
> +.B Elf * elf_memory(char *" image ", size_t" size ");

OK.

> +.fi
> +.SH DESCRIPTION
> +The
> +.BR elf_memory ()
> +function creates a new ELF descriptor from a memory region containing an ELF
> +object.  This function is used when the ELF data is already present in memory
> +rather than being read from a file descriptor.
> +
> +The memory pointed to by
> +.I image
> +must contain a complete ELF file or archive. The contents must remain valid
> +and unmodified for the lifetime of the resulting ELF descriptor.
> +
> +The ELF descriptor returned by
> +.BR elf_memory ()
> +is opened in read-only mode using ELF_C_READ_MMAP_PRIVATE (see
> +.BR elf_begin ).
> +The underlying memory image should not be directly modified by the 
> application 
> +while its ELF descriptor is open.  Some libelf functions, such as
> +.BR elf_compress ()
> +and
> +.BR gelf_update_* (),
> +may internally modify the underlying image and therefore require that the
> +underlying image be writable.  The use of a read-only image (e.g., memory
> +mapped with
> +.BR PROT_READ
> +only) may result in failures or crashes. 

Nice.

> +
> +.SH PARAMETERS
> +.TP
> +.I image
> +A pointer to a memory buffer that contains the complete contents of an ELF 
> file
> +or archive. If NULL, this function fails and returns NULL.

OK.

> +.TP
> +.I size
> +The size in bytes of the memory region pointed to by
> +.IR image .
> +Must be at least as much as a full ELF header and should cover the entire ELF
> +object.

OK.

> +.SH RETURN VALUE
> +On success,
> +.BR elf_memory ()
> +returns a pointer to an
> +.B Elf
> +descriptor representing the archive or ELF file contained in
> +.IR image .
> +
> +On failure, it returns NULL and sets an error code retrievable by
> +.BR elf_errmsg (3).

OK.

> +.SH SEE ALSO
> +.BR elf_begin (3),
> +.BR elf_errmsg (3),
> +.BR libelf (3),
> +.BR elf (5) 

OK.

> +.SH ATTRIBUTES
> +.TS
> +allbox;
> +lbx lb lb
> +l l l.
> +Interface   Attribute   Value
> +T{
> +.na
> +.nh
> +.BR elf_memory ()
> +T}  Thread safety   MT-Safe
> +.TE
> +
> +.SH REPORTING BUGS
> +Report bugs to  or 
> https://sourceware.org/bugzilla/.
> +

OK.

Thanks,

Mark