[Bug libdw/31447] Provide a public debug section relocation function

2024-05-12 Thread dichen at redhat dot com
https://sourceware.org/bugzilla/show_bug.cgi?id=31447

--- Comment #2 from Di Chen  ---
Hey @mjw

```
$ eu-readelf -a qq.o | grep Type
  Type: REL (Relocatable file)

$ eu-readelf -S qq.o | grep REL
[ 2] .rela.text   RELA  04b8 0048 24 I 
   19   1  8
[ 6] .rela.debug_info RELA  0500 00f0 24 I 
   19   5  8
[ 9] .rela.debug_aranges  RELA  05f0 0030 24 I 
   19   8  8
[11] .rela.debug_line RELA  0620 0060 24 I 
   19  10  8
[18] .rela.eh_frame   RELA  0680 0030 24 I 
   19  17  8

```


When applying relocation on a relocatable file (the above qq.o) with the new
function
dwelf_relocation_debug_sections (Elf *elf), it only needs to apply relocation
on debug sections (which are 
[ 6] .rela.debug_info, 
[ 9] .rela.debug_aranges,
[11] .rela.debug_line
), am I right?

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

[Bug libdw/31447] Provide a public debug section relocation function

2024-05-12 Thread mark at klomp dot org
https://sourceware.org/bugzilla/show_bug.cgi?id=31447

--- Comment #3 from Mark Wielaard  ---
Yes, just process the .rela.debug_* sections.
Note that you don't need to depend on the exact name.
You can follow the section header sh_info field, which points to the section
(number) to which the relocations apply.
If that section starts with .debug you can apply the relocations.
Or better use ebl_debugscn_p, which checks against the list in
libebl/eblopenbackend.c (default_debugscn_p).

See also in strip.c, where it says:

  /* Make sure that this relocation section points to a
 section to relocate with contents, that isn't
 allocated and that is a debug section.  */

Or libdwfl/relocate.c (relocate_section). Which contains similar logic.

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

Re: [PATCH] ar: Replace one alloca use by xmalloc

2024-05-12 Thread Mark Wielaard
Hi Aaron,

On Fri, May 10, 2024 at 05:16:06PM -0400, Aaron Merey wrote:
> On Tue, Apr 30, 2024 at 10:39 AM Mark Wielaard  wrote:
> >
> > This alloca use is inside a lexical block and is used to replace one
> > element of argv. Use a function local variable, xmalloc and free to
> > make memory usage pattern more clear.
> >
> > * src/ar.c (main): Move newp char pointer declaration up.
> > Use xmalloc to allocate space. free at end of main.
> >
> > Signed-off-by: Mark Wielaard 
> 
> LGTM. This patch shouldn't change anything except possibly help
> some static analyzers detect correct memory usage.

Thanks. Pushed as commit 3c71cab7c5bfba0549d0a1716e7061d07eafd794

Cheers,

Mark