This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: PATCH: Fix readelf segment map
I will check in this patch as an obvious fix.
H.J.
---
On Thu, Feb 02, 2006 at 03:04:46PM -0800, H. J. Lu wrote:
> On Thu, Feb 02, 2006 at 02:56:11PM -0800, H. J. Lu wrote:
> > Apparently, I was wrong. I tried to fix
> >
> > [hjl@gnu-13 strip-4]$ readelf -l a.out
> >
> > Elf file type is EXEC (Executable file)
> > Entry point 0x401108
> > There are 3 program headers, starting at offset 64
> >
> > Program Headers:
> > Type Offset VirtAddr PhysAddr
> > FileSiz MemSiz Flags Align
> > LOAD 0x0000000000000000 0x0000000000400000
> > 0x0000000000400000
> > 0x00000000000011fc 0x00000000000011fc R E 100000
> > LOAD 0x00000000000011fc 0x00000000005011fc
> > 0x00000000005011fc
> > 0x000000000000009c 0x000000000000009c RW 100000
> > TLS 0x00000000000011fc 0x00000000005011fc
> > 0x00000000005011fc
> > 0x0000000000000080 0x00000000000000c0 R 1
> >
> > Section to Segment mapping:
> > Segment Sections...
> > 00 .text
> > 01 .tdata .got.plt
> > 02 .tdata .tbss .got.plt
> >
> > The last one should be
> >
> > 02 .tdata .tbss
> >
> > I backed out my last change.
> >
>
> That is the updated patch.
>
>
> H.J.
> ---
> 2006-02-02 H.J. Lu <hongjiu.lu@intel.com>
>
> * readelf.c (process_program_headers): Match PT_TLS segment
> only with SHT_TLS sections.
>
> --- binutils/readelf.c.tls 2006-02-02 14:53:46.000000000 -0800
> +++ binutils/readelf.c 2006-02-02 15:02:03.000000000 -0800
> @@ -3405,6 +3405,9 @@ process_program_headers (FILE *file)
> for (j = 1; j < elf_header.e_shnum; j++, section++)
> {
> if (section->sh_size > 0
> + /* PT_TLS segment contains only SHF_TLS sections. */
> + && (segment->p_type != PT_TLS
> + || (section->sh_flags & SHF_TLS) != 0)
> /* Compare allocated sections by VMA, unallocated
> sections by file offset. */
> && (section->sh_flags & SHF_ALLOC