public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* 64-bit pei vs dwarf2
@ 2010-09-28 10:44 Richard Henderson
  2010-09-28 12:28 ` Dave Korn
                   ` (2 more replies)
  0 siblings, 3 replies; 10+ messages in thread
From: Richard Henderson @ 2010-09-28 10:44 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Kai Tietz, gcc

The 64-bit PEI format has a SECREL32 relocation type.  It
does not, however, have a SECREL64 relocation type.  Which
means that for

> #define DWARF_REF_SIZE  \
>   (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)

we don't really have something to use for for dwarf2.

I could fake it with

	.secrel32	ref
	.long		0

but it seems better simply to force the use of dwarf3
for this target.  Suggestions about how to go about this
within the tangled mess of option processing?


r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 10:44 64-bit pei vs dwarf2 Richard Henderson
@ 2010-09-28 12:28 ` Dave Korn
  2010-09-28 15:21 ` Kai Tietz
  2010-09-28 16:41 ` Jakub Jelinek
  2 siblings, 0 replies; 10+ messages in thread
From: Dave Korn @ 2010-09-28 12:28 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jakub Jelinek, Kai Tietz, gcc

On 28/09/2010 01:29, Richard Henderson wrote:
> The 64-bit PEI format has a SECREL32 relocation type.  It
> does not, however, have a SECREL64 relocation type.  Which
> means that for
> 
>> #define DWARF_REF_SIZE  \
>>   (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
> 
> we don't really have something to use for for dwarf2.
> 
> I could fake it with
> 
> 	.secrel32	ref
> 	.long		0
> 
> but it seems better simply to force the use of dwarf3
> for this target.  Suggestions about how to go about this
> within the tangled mess of option processing?

  Override PREFERRED_DEBUGGING_TYPE in mingw-w64.h?

    cheers,
      DaveK

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 10:44 64-bit pei vs dwarf2 Richard Henderson
  2010-09-28 12:28 ` Dave Korn
@ 2010-09-28 15:21 ` Kai Tietz
  2010-09-28 16:29   ` Kai Tietz
  2010-09-28 16:41 ` Jakub Jelinek
  2 siblings, 1 reply; 10+ messages in thread
From: Kai Tietz @ 2010-09-28 15:21 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jakub Jelinek, gcc

2010/9/28 Richard Henderson <rth@twiddle.net>:
> The 64-bit PEI format has a SECREL32 relocation type.  It
> does not, however, have a SECREL64 relocation type.  Which
> means that for
>
>> #define DWARF_REF_SIZE  \
>>   (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
>
> we don't really have something to use for for dwarf2.
>
> I could fake it with
>
>        .secrel32       ref
>        .long           0
>
> but it seems better simply to force the use of dwarf3
> for this target.  Suggestions about how to go about this
> within the tangled mess of option processing?
>
>
> r~
>

Well, dwarf-3 is ok, if it helps to solve the issue. On the other hand
to fake it by secrel32   ref ; .long 0 looks not wrong to me. As PE+
is limited in image size to 2GB there should be any issue about it. A
section relative offset can't get bigger then 2^31 bits.
We could introduce here a .seclrel64 relocation, but wouldn't be
covered by standard.

Cheers,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 15:21 ` Kai Tietz
@ 2010-09-28 16:29   ` Kai Tietz
  0 siblings, 0 replies; 10+ messages in thread
From: Kai Tietz @ 2010-09-28 16:29 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jakub Jelinek, gcc

2010/9/28 Kai Tietz <ktietz70@googlemail.com>:
> 2010/9/28 Richard Henderson <rth@twiddle.net>:
>> The 64-bit PEI format has a SECREL32 relocation type.  It
>> does not, however, have a SECREL64 relocation type.  Which
>> means that for
>>
>>> #define DWARF_REF_SIZE  \
>>>   (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
>>
>> we don't really have something to use for for dwarf2.
>>
>> I could fake it with
>>
>>        .secrel32       ref
>>        .long           0
>>
>> but it seems better simply to force the use of dwarf3
>> for this target.  Suggestions about how to go about this
>> within the tangled mess of option processing?
>>
>>
>> r~
>>
>
> Well, dwarf-3 is ok, if it helps to solve the issue. On the other hand
> to fake it by secrel32   ref ; .long 0 looks not wrong to me. As PE+
> is limited in image size to 2GB there should be any issue about it. A
> section relative offset can't get bigger then 2^31 bits.
> We could introduce here a .seclrel64 relocation, but wouldn't be
> covered by standard.
>
> Cheers,
> Kai
>
> --
> |  (\_/) This is Bunny. Copy and paste
> | (='.'=) Bunny into your signature to help
> | (")_(") him gain world domination
>

The fix would be then in cygming.h ASM_OUTPUT_DWARF_OFFSET to emit for
64-bit, if SIZE == 8, an additional .long 0 after the .secrel32.

Regards,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 10:44 64-bit pei vs dwarf2 Richard Henderson
  2010-09-28 12:28 ` Dave Korn
  2010-09-28 15:21 ` Kai Tietz
@ 2010-09-28 16:41 ` Jakub Jelinek
  2010-09-28 17:07   ` Kai Tietz
  2 siblings, 1 reply; 10+ messages in thread
From: Jakub Jelinek @ 2010-09-28 16:41 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Kai Tietz, gcc

On Mon, Sep 27, 2010 at 05:29:19PM -0700, Richard Henderson wrote:
> The 64-bit PEI format has a SECREL32 relocation type.  It
> does not, however, have a SECREL64 relocation type.  Which
> means that for
> 
> > #define DWARF_REF_SIZE  \
> >   (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
> 
> we don't really have something to use for for dwarf2.
> 
> I could fake it with
> 
> 	.secrel32	ref
> 	.long		0

This is something we already use for TLS on x86_64:
        .byte   0xa     # DW_AT_location
        .byte   0xe     # DW_OP_const8u
        .long   i@dtpoff, 0
At least for relocations that are always resolved to locations
within the same .debug_info section they will be always unsigned
and thus using .secrel 32 ref; .long 0 is IMHO just fine, and
implicit pointer currently will never reference anything outside of the
current executable's or shared library's CU.

Other alternative would be e.g. to have some macro to protect uses of
DW_FORM_ref_addr/DW_OP_GNU_implicit_pointer/DW_OP_call_ref,
which by default would be to enable them e.g. for
(dwarf_version >= 3 || !dwarf_strict) and targets
like this could restrict them to (dwarf_version >= 3).

	Jakub

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 16:41 ` Jakub Jelinek
@ 2010-09-28 17:07   ` Kai Tietz
  2010-09-28 17:22     ` Andrew Haley
  2010-09-28 19:21     ` Richard Henderson
  0 siblings, 2 replies; 10+ messages in thread
From: Kai Tietz @ 2010-09-28 17:07 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Richard Henderson, gcc

[-- Attachment #1: Type: text/plain, Size: 1585 bytes --]

2010/9/28 Jakub Jelinek <jakub@redhat.com>:
> On Mon, Sep 27, 2010 at 05:29:19PM -0700, Richard Henderson wrote:
>> The 64-bit PEI format has a SECREL32 relocation type.  It
>> does not, however, have a SECREL64 relocation type.  Which
>> means that for
>>
>> > #define DWARF_REF_SIZE  \
>> >   (dwarf_version == 2 ? DWARF2_ADDR_SIZE : DWARF_OFFSET_SIZE)
>>
>> we don't really have something to use for for dwarf2.
>>
>> I could fake it with
>>
>>       .secrel32       ref
>>       .long           0
>
> This is something we already use for TLS on x86_64:
>        .byte   0xa     # DW_AT_location
>        .byte   0xe     # DW_OP_const8u
>        .long   i@dtpoff, 0
> At least for relocations that are always resolved to locations
> within the same .debug_info section they will be always unsigned
> and thus using .secrel 32 ref; .long 0 is IMHO just fine, and
> implicit pointer currently will never reference anything outside of the
> current executable's or shared library's CU.

So I suggest the following patch. I tested it for x86_64-w64-mingw32
and didn't got regressions. Also the eh/register1.C test produces
correct abbreviations (tested by objdump -Wi).

ChangeLog

2010-09-28  Kai Tietz

          * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Output
          addition zero for padding of secrel32 requested for 8 bytes.

I will apply this today, if there aren't any objections.

Regards,
Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

[-- Attachment #2: w64_secrel.diff --]
[-- Type: application/octet-stream, Size: 494 bytes --]

Index: gcc/gcc/config/i386/cygming.h
===================================================================
--- gcc.orig/gcc/config/i386/cygming.h	2010-09-02 09:34:57.000000000 +0200
+++ gcc/gcc/config/i386/cygming.h	2010-09-28 09:49:57.435061800 +0200
@@ -78,6 +78,8 @@ along with GCC; see the file COPYING3.  
 								\
     fputs ("\t.secrel32\t", FILE);				\
     assemble_name (FILE, LABEL);				\
+    if (SIZE == 8)						\
+      fputs ("\n\t.long\t0", FILE);				\
   } while (0)
 #endif
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 17:07   ` Kai Tietz
@ 2010-09-28 17:22     ` Andrew Haley
  2010-09-28 19:21     ` Richard Henderson
  1 sibling, 0 replies; 10+ messages in thread
From: Andrew Haley @ 2010-09-28 17:22 UTC (permalink / raw)
  To: Kai Tietz; +Cc: gcc

On 09/28/2010 11:09 AM, Kai Tietz wrote:

> ChangeLog
> 
> 2010-09-28  Kai Tietz
> 
>           * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Output
>           addition zero for padding of secrel32 requested for 8 bytes.
> 
> I will apply this today, if there aren't any objections.

Please don't send diffs as Content-Type: application/octet-stream.

Thanks,
Andrew.

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 17:07   ` Kai Tietz
  2010-09-28 17:22     ` Andrew Haley
@ 2010-09-28 19:21     ` Richard Henderson
  2010-09-28 21:24       ` Kai Tietz
  1 sibling, 1 reply; 10+ messages in thread
From: Richard Henderson @ 2010-09-28 19:21 UTC (permalink / raw)
  To: Kai Tietz; +Cc: Jakub Jelinek, gcc

[-- Attachment #1: Type: text/plain, Size: 321 bytes --]

On 09/28/2010 03:09 AM, Kai Tietz wrote:
>           * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Output
>           addition zero for padding of secrel32 requested for 8 bytes.
> 
> I will apply this today, if there aren't any objections.

I've committed the following instead, which I think is a bit tidier.


r~

[-- Attachment #2: z --]
[-- Type: text/plain, Size: 1345 bytes --]

        * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Output 8 bytes
        when 8 bytes are requested.                             


diff --git a/gcc/config/i386/cygming.h b/gcc/config/i386/cygming.h
index 3fee731..ed6b459 100644
--- a/gcc/config/i386/cygming.h
+++ b/gcc/config/i386/cygming.h
@@ -96,11 +96,25 @@ along with GCC; see the file COPYING3.  If not see
    won't allow it.  */
 #define ASM_OUTPUT_DWARF_OFFSET(FILE, SIZE, LABEL, SECTION)	\
   do {								\
-    if (SIZE != 4 && (!TARGET_64BIT || SIZE != 8))		\
-      abort ();							\
-								\
-    fputs ("\t.secrel32\t", FILE);				\
-    assemble_name (FILE, LABEL);				\
+    switch (SIZE)						\
+      {								\
+      case 4:							\
+	fputs ("\t.secrel32\t", FILE);				\
+	assemble_name (FILE, LABEL);				\
+	break;							\
+      case 8:							\
+	/* This is a hack.  There is no 64-bit section relative	\
+	   relocation.  However, the COFF format also does not	\
+	   support 64-bit file offsets; 64-bit applications are	\
+	   limited to 32-bits of code+data in any one module.	\
+	   Fake the 64-bit offset by zero-extending it.  */	\
+	fputs ("\t.secrel32\t", FILE);				\
+	assemble_name (FILE, LABEL);				\
+	fputs ("\n\t.long\t0", FILE);				\
+	break;							\
+      default:							\
+	gcc_unreachable ();					\
+      }								\
   } while (0)
 #endif
 

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 19:21     ` Richard Henderson
@ 2010-09-28 21:24       ` Kai Tietz
  2010-09-28 22:51         ` Richard Henderson
  0 siblings, 1 reply; 10+ messages in thread
From: Kai Tietz @ 2010-09-28 21:24 UTC (permalink / raw)
  To: Richard Henderson; +Cc: Jakub Jelinek, gcc

2010/9/28 Richard Henderson <rth@twiddle.net>:
> On 09/28/2010 03:09 AM, Kai Tietz wrote:
>>           * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Output
>>           addition zero for padding of secrel32 requested for 8 bytes.
>>
>> I will apply this today, if there aren't any objections.
>
> I've committed the following instead, which I think is a bit tidier.
>
>
> r~
>

Ok, thanks for tracking this issue. In my opinion it would be good to
back-merge this patch to branches.

Kai

-- 
|  (\_/) This is Bunny. Copy and paste
| (='.'=) Bunny into your signature to help
| (")_(") him gain world domination

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: 64-bit pei vs dwarf2
  2010-09-28 21:24       ` Kai Tietz
@ 2010-09-28 22:51         ` Richard Henderson
  0 siblings, 0 replies; 10+ messages in thread
From: Richard Henderson @ 2010-09-28 22:51 UTC (permalink / raw)
  To: Kai Tietz; +Cc: Jakub Jelinek, gcc

On 09/28/2010 09:50 AM, Kai Tietz wrote:
> 2010/9/28 Richard Henderson <rth@twiddle.net>:
>> On 09/28/2010 03:09 AM, Kai Tietz wrote:
>>>           * config/i386/cygming.h (ASM_OUTPUT_DWARF_OFFSET): Output
>>>           addition zero for padding of secrel32 requested for 8 bytes.
>>>
>>> I will apply this today, if there aren't any objections.
>>
>> I've committed the following instead, which I think is a bit tidier.
>>
>>
>> r~
>>
> 
> Ok, thanks for tracking this issue. In my opinion it would be good to
> back-merge this patch to branches.

I've committed it to 4.5 for good measure, but this really only
matters for mainline with the DW_OP_GNU_implicit_pointer support.
Prior to that we never emitted any opcodes with references.


r~

^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2010-09-28 17:07 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-28 10:44 64-bit pei vs dwarf2 Richard Henderson
2010-09-28 12:28 ` Dave Korn
2010-09-28 15:21 ` Kai Tietz
2010-09-28 16:29   ` Kai Tietz
2010-09-28 16:41 ` Jakub Jelinek
2010-09-28 17:07   ` Kai Tietz
2010-09-28 17:22     ` Andrew Haley
2010-09-28 19:21     ` Richard Henderson
2010-09-28 21:24       ` Kai Tietz
2010-09-28 22:51         ` Richard Henderson

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).