From d17f9de52545417d7fec051b8e1b144234956021 Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 26 Apr 2010 13:09:33 -0700 Subject: [PATCH] libdwfl: Treat R_*_NONE reloc as no reloc. --- libdwfl/ChangeLog | 6 ++++++ libdwfl/relocate.c | 11 ++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog index 54ac53fac..a9f36d96d 100644 --- a/libdwfl/ChangeLog +++ b/libdwfl/ChangeLog @@ -1,3 +1,9 @@ +2010-04-26 Roland McGrath + + * relocate.c (relocate_section): Treat R_*_NONE reloc as no reloc. + Works around probably-wrong ld -r behavior for case of a DWARF address + constant that refers to a discarded SHF_ALLOC section. + 2010-04-14 Roland McGrath * link_map.c (report_r_debug): Limit iterations on the l_next chain to diff --git a/libdwfl/relocate.c b/libdwfl/relocate.c index 121a481be..0075c7f90 100644 --- a/libdwfl/relocate.c +++ b/libdwfl/relocate.c @@ -1,5 +1,5 @@ /* Relocate debug information. - Copyright (C) 2005-2009 Red Hat, Inc. + Copyright (C) 2005-2010 Red Hat, Inc. This file is part of Red Hat elfutils. Red Hat elfutils is free software; you can redistribute it and/or modify @@ -325,6 +325,15 @@ relocate_section (Dwfl_Module *mod, Elf *relocated, const GElf_Ehdr *ehdr, { /* First see if this is a reloc we can handle. If we are skipping it, don't bother resolving the symbol. */ + + if (unlikely (rtype == 0)) + /* In some odd situations, the linker can leave R_*_NONE relocs + behind. This is probably bogus ld -r behavior, but the only + cases it's known to appear in are harmless: DWARF data + referring to addresses in a section that has been discarded. + So we just pretend it's OK without further relocation. */ + return DWFL_E_NOERROR; + Elf_Type type = ebl_reloc_simple_type (mod->ebl, rtype); if (unlikely (type == ELF_T_NUM)) return DWFL_E_BADRELTYPE; -- 2.47.2