public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
From: Pedro Alves <palves@redhat.com>
To: Pierre Muller <pierre.muller@ics-cnrs.unistra.fr>
Cc: "'Joel Brobecker'" <brobecker@adacore.com>, gdb-patches@sourceware.org
Subject: Re: [RFA-v2] Fix PR 16201: internal error on a cygwin program linked against a DLL with no .data section
Date: Fri, 20 Dec 2013 18:19:00 -0000	[thread overview]
Message-ID: <52B48A28.2000402@redhat.com> (raw)
In-Reply-To: <52ab7ec0.c8da420a.12c6.ffffb3f4SMTPIN_ADDED_BROKEN@mx.google.com>

On 12/13/2013 09:39 PM, Pierre Muller wrote:
> 

>> I just re-read the code, and I really think it would be better if
>> someone who actually understands the general framework could comment.
>> The problem seems, as you stated, relatively well understood, but
>> I am not sure how we are expected to fix it.
>>
>>> 2013-11-27  Pierre Muller  <muller@sourceware.org>
>>>
>>>         PR 16201
>>>         coff-pe-read.c (read_pe_exported_syms): Set sect_index_text,

Missing '*'

>>>         sect_index_data and sect_index_bss of objfile struct, even if
>>>         there is no canonical '.text', '.data' or '.bss' named
>> section.
>>
>> My only comment is that the patch could gain from some additional
>> comments explaining _why_ you're forcing the sect_index field
>> ("event if already set before"), and what you are trying to achieve.
> 
> Here is a new version in which I try to explain
> more clearly that if we find the canonical
>  '.text', '.data' or '.bss' section names,
> we should use these sections to set sect_index_XXX.
> Otherwise, we use the first section that is used later with
> for which we set ms_type to mst_XXX to also set sect_index_XXX.
>   This ensure that sect_index_XXX is always set if
> any exported symbol is in inserted using
> prim_rcord_minimal_symbol with ms_type parameter set to mst_XXX
> 
> I hope this clarifies the patch .
> 

So in the DLL in question, there was no .data section, but
there was another section with IMAGE_SCN_CNT_INITIALIZED_DATA set.
What was this section?  From the PR:

$ objdump -h icudt49.dll

icudt49.dll:     file format pei-i386

Sections:
Idx Name          Size      VMA       LMA       File off  Algn
  0 .rdata        0111f4fa  10001000  10001000  00000400  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA
  1 .rsrc         00000458  11121000  11121000  0111fa00  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, DATA

From the PR, we see the dll exported a icudt49_dat symbol:

...
#1  0x0054ae16 in prim_record_minimal_symbol (name=name@entry=0x8019db78 "icudt49!icudt49_dat",
    address=address@entry=1585713152, ms_type=mst_data,
    objfile=objfile@entry=0x8027a9c8)
...

So the fix is this part:

          else if (characteristics & IMAGE_SCN_CNT_INITIALIZED_DATA)
-           section_data[otherix].ms_type = mst_data;
+           {
+             section_data[otherix].ms_type = mst_data;
+             if (objfile->sect_index_data == -1)
+             objfile->sect_index_data = otherix;
+           }


It's not clear to me that forcing sect_index_... when the
canonical section is found is better than using the
first / lowest section that looks like code/data/bss.  I'd
suggest just taking the first found.  IOW, do:

             if (objfile->sect_index_data == -1)
             objfile->sect_index_data = otherix;

in the other branch too.

But, hmmm, don't we know the symbol's section?
Wouldn't it be even better to make add_pe_exported_sym
call prim_record_minimal_symbol_and_info directly,
rather than prim_record_minimal_symbol ?

-- 
Pedro Alves

  parent reply	other threads:[~2013-12-20 18:19 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-11 10:50 [PING RFA] " Pierre Muller
2013-12-11 17:02 ` Joel Brobecker
2013-12-13 21:40   ` [RFA-v2] " Pierre Muller
2013-12-18  3:55     ` Joel Brobecker
     [not found]   ` <52ab7ec0.c8da420a.12c6.ffffb3f4SMTPIN_ADDED_BROKEN@mx.google.com>
2013-12-20 18:19     ` Pedro Alves [this message]
2013-12-22 22:56       ` Pierre Muller
     [not found]       ` <15250.2735647888$1387752987@news.gmane.org>
2013-12-23  2:31         ` asmwarrior
     [not found]       ` <52b76e14.8886420a.29e6.ffffddb2SMTPIN_ADDED_BROKEN@mx.google.com>
2014-01-06 18:34         ` Pedro Alves
2014-01-07 11:15           ` [RFA-v3] " Pierre Muller
     [not found]           ` <52cbe1c5.67ed440a.67e6.7288SMTPIN_ADDED_BROKEN@mx.google.com>
2014-01-07 20:58             ` Pedro Alves
2014-01-07 23:40               ` [COMMIT-v4] " Pierre Muller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=52B48A28.2000402@redhat.com \
    --to=palves@redhat.com \
    --cc=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    --cc=pierre.muller@ics-cnrs.unistra.fr \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).