Re: readelf: Save and dump the original section header values

Project / Subsystem

binutils / readelf

Date

2026-07-12

Proposer

Alan Modra <amodra@gmail.com>

Source type

public_inbox

Consensus

Proposed

Sentiment

/10

Technical tradeoffs

  • Simplifies error messages, potentially losing some specific detail about malloc failures for small allocations.
  • Introduces 'xmalloc' for safer memory allocation, which might have slightly different behavior than raw 'malloc' in error cases.

All attributes

project
binutils
subsystem
readelf
patch_id
discussion_id
alNf0yuNAobHT3dV@squeak.grove.modra.org
source_type
public_inbox
title
Re: readelf: Save and dump the original section header values
headline
readelf: Save and dump the original section header values
tldr
Improves error handling and fixes a buffer overflow in binutils' readelf tool.
proposer
Alan Modra <amodra@gmail.com>
consensus
Proposed
outcome
proposed
sentiment_score
technical_tradeoffs
  • Simplifies error messages, potentially losing some specific detail about malloc failures for small allocations.
  • Introduces 'xmalloc' for safer memory allocation, which might have slightly different behavior than raw 'malloc' in error cases.
series_id
series_role
standalone
series_parts
[]
tags
  • binutils
  • readelf
  • elf
  • bugfix
  • error-handling
bugzilla_url
date
2026-07-12T00:00:00.000Z

Re: readelf: Save and dump the original section header values

This patch refactors parts of binutils’ readelf.c to improve error reporting for malloc failures and fix a potential buffer overflow in orig_section_headers. It simplifies warning messages, removes unused parameters, and adjusts memory allocation and validation logic, particularly when probing ELF headers or handling relr dynamic tags.