* [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries
@ 2009-07-20 1:55 Thiago Jung Bauermann
2009-07-20 4:13 ` Paul Pluzhnikov
0 siblings, 1 reply; 5+ messages in thread
From: Thiago Jung Bauermann @ 2009-07-20 1:55 UTC (permalink / raw)
To: gdb; +Cc: Joel Brobecker
Hi,
One painful aspect of GDB right now is that it doesn't handle PIE (Position
Independent Executable) and doesn't even recognize a PIE binary when it sees
one. I have an action item for 7.0 which is to make GDB at least complain that
it is being given such a binary and warn the user appropriately. That would be
enough to close the bugzilla in the subject and ship 7.0 (as we have discussed
before in this mailing list).
Then for 7.1 somebody could push upstream one of the two circulating patches
which implement PIE support, and close PR/9174 (gdb can't handle PIE).
All this to say: can somebody save me some research time and tell in high
level how can I recognize from looking at an ELF file that I'm dealing with a
PIE binary (NOT a PIC library, of course)? Something like "see if the frob bit
in the bozo section is set") is enough, I can go from there.
--
[]'s
Thiago Jung Bauermann
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries
2009-07-20 1:55 [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries Thiago Jung Bauermann
@ 2009-07-20 4:13 ` Paul Pluzhnikov
2009-07-25 2:11 ` Thiago Jung Bauermann
0 siblings, 1 reply; 5+ messages in thread
From: Paul Pluzhnikov @ 2009-07-20 4:13 UTC (permalink / raw)
To: Thiago Jung Bauermann; +Cc: gdb, Joel Brobecker
On Sun, Jul 19, 2009 at 6:57 PM, Thiago Jung
Bauermann<thiago.bauermann@gmail.com> wrote:
> All this to say: can somebody save me some research time and tell in high
> level how can I recognize from looking at an ELF file that I'm dealing with a
> PIE binary (NOT a PIC library, of course)? Something like "see if the frob bit
> in the bozo section is set") is enough, I can go from there.
Elf*_Ehdr.e_type == ET_DYN for the main executable?
Elf*_Phdr.p_vaddr == 0 for the first PT_LOAD segment?
[This one is only true for non-prelinked -pie executable.]
Cheers,
--
Paul Pluzhnikov
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries
2009-07-20 4:13 ` Paul Pluzhnikov
@ 2009-07-25 2:11 ` Thiago Jung Bauermann
2009-07-25 2:26 ` Daniel Jacobowitz
2009-07-25 9:56 ` Mark Kettenis
0 siblings, 2 replies; 5+ messages in thread
From: Thiago Jung Bauermann @ 2009-07-25 2:11 UTC (permalink / raw)
To: Paul Pluzhnikov; +Cc: gdb, Joel Brobecker
Em Segunda-feira 20 Julho 2009 01:13:00 Paul Pluzhnikov escreveu:
> On Sun, Jul 19, 2009 at 6:57 PM, Thiago Jung
>
> Bauermann<thiago.bauermann@gmail.com> wrote:
> > All this to say: can somebody save me some research time and tell in high
> > level how can I recognize from looking at an ELF file that I'm dealing
> > with a PIE binary (NOT a PIC library, of course)? Something like "see if
> > the frob bit in the bozo section is set") is enough, I can go from there.
>
> Elf*_Ehdr.e_type == ET_DYN for the main executable?
>
> Elf*_Phdr.p_vaddr == 0 for the first PT_LOAD segment?
> [This one is only true for non-prelinked -pie executable.]
Great, thanks for the tip. Since nobody jumped into discussion, I assume any
of those ways will work and have no known side-effect or false
positive/negative. We'll see. :-)
Now I have this issue, I'd like to ask people's opinion about it: by design
(or defect?) the BFD library is a PITA to access the program header. I feel
very tempted to use elf32.h and elf64.h directly in order to check that field.
My only worry is that a cross-debugging session with a win32 gdb and a linux
remote target would not be possible, unless windows includes such sysv elf
headers too (perhaps it does?).
Do you have an opinion?
--
[]'s
Thiago Jung Bauermann
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries
2009-07-25 2:11 ` Thiago Jung Bauermann
@ 2009-07-25 2:26 ` Daniel Jacobowitz
2009-07-25 9:56 ` Mark Kettenis
1 sibling, 0 replies; 5+ messages in thread
From: Daniel Jacobowitz @ 2009-07-25 2:26 UTC (permalink / raw)
To: Thiago Jung Bauermann; +Cc: Paul Pluzhnikov, gdb, Joel Brobecker
On Fri, Jul 24, 2009 at 11:12:41PM -0300, Thiago Jung Bauermann wrote:
> Now I have this issue, I'd like to ask people's opinion about it: by design
> (or defect?) the BFD library is a PITA to access the program header. I feel
> very tempted to use elf32.h and elf64.h directly in order to check that field.
> My only worry is that a cross-debugging session with a win32 gdb and a linux
> remote target would not be possible, unless windows includes such sysv elf
> headers too (perhaps it does?).
elfread.c:elf_symfile_segments. It's not much of a pain really?
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries
2009-07-25 2:11 ` Thiago Jung Bauermann
2009-07-25 2:26 ` Daniel Jacobowitz
@ 2009-07-25 9:56 ` Mark Kettenis
1 sibling, 0 replies; 5+ messages in thread
From: Mark Kettenis @ 2009-07-25 9:56 UTC (permalink / raw)
To: thiago.bauermann; +Cc: ppluzhnikov, gdb, brobecker
> From: Thiago Jung Bauermann <thiago.bauermann@gmail.com>
> Date: Fri, 24 Jul 2009 23:12:41 -0300
>
> Em Segunda-feira 20 Julho 2009 01:13:00 Paul Pluzhnikov escreveu:
> > On Sun, Jul 19, 2009 at 6:57 PM, Thiago Jung
> >
> > Bauermann<thiago.bauermann@gmail.com> wrote:
> > > All this to say: can somebody save me some research time and tell in high
> > > level how can I recognize from looking at an ELF file that I'm dealing
> > > with a PIE binary (NOT a PIC library, of course)? Something like "see if
> > > the frob bit in the bozo section is set") is enough, I can go from there.
> >
> > Elf*_Ehdr.e_type == ET_DYN for the main executable?
> >
> > Elf*_Phdr.p_vaddr == 0 for the first PT_LOAD segment?
> > [This one is only true for non-prelinked -pie executable.]
>
> Great, thanks for the tip. Since nobody jumped into discussion, I assume any
> of those ways will work and have no known side-effect or false
> positive/negative. We'll see. :-)
Well, I'm not sure the second method is something you can rely on. I
think Elf*_Phdr.p_vaddr can be 0 for non-PIC executables as well on
some architectures.
> Now I have this issue, I'd like to ask people's opinion about it: by
> design (or defect?) the BFD library is a PITA to access the program
> header. I feel very tempted to use elf32.h and elf64.h directly in
> order to check that field. My only worry is that a cross-debugging
> session with a win32 gdb and a linux remote target would not be
> possible, unless windows includes such sysv elf headers too (perhaps
> it does?).
>
> Do you have an opinion?
Which elf32.h and elf64.h. I don't think those are standardized
headers in any way. Defenitely no files with those names under
/usr/include on OpenBSD. Heck, even my Linux workstation at work
doesn't have any files named like that.
There is "elf/common.h" in the src tree though.
Anyway, if the BFD library doesn't provide some functionality you
need, I think the best thing to do would be to add it there. There
seems to be an Elf_Internal_Phdr pointer in struct elf_obj_tdata, so
perhaps the only thing you need to add is a macro like elf_elfheader()
to access it.
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2009-07-25 9:56 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-07-20 1:55 [7.0] PR/9723: gdb breakpoints silently fail on PIE binaries Thiago Jung Bauermann
2009-07-20 4:13 ` Paul Pluzhnikov
2009-07-25 2:11 ` Thiago Jung Bauermann
2009-07-25 2:26 ` Daniel Jacobowitz
2009-07-25 9:56 ` Mark Kettenis
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox