* [PATCH]: Add DWARF debugging format support for arm-wince-pe
@ 2006-08-05 0:39 Pedro Alves
2006-08-05 3:20 ` Daniel Jacobowitz
2006-08-05 6:57 ` Andreas Schwab
0 siblings, 2 replies; 10+ messages in thread
From: Pedro Alves @ 2006-08-05 0:39 UTC (permalink / raw)
To: binutils
[-- Attachment #1: Type: text/plain, Size: 2358 bytes --]
Hi all,
The attached patches to bfd, gas and ld's testsuite,
add DWARF debugging format support to arm-wince-pe.
The work is based on the i386 coff ports.
It resolves (mostly) around:
- Moving dwarf related present code out of elf only blocks.
- Handling the dwarf related pseudos.
- Handling the .secrel32 pseudo, and consequently,
- Handling the section relative relocs.
Tested on arm-wince-pe and arm-none-eabi for binutils regressions,
and with arm-wince-gdb.
I don't know which is the correct value to return in
bfd_get_sign_extend_vma. I tested it with 1 and 0, but found no
difference.
What is the correct value? How does one test for it?
Cheers,
Pedro Alves
---
bfd/ChangeLog
2006-08-05 Pedro Alves <pedro_alves@portugalmail.pt>
* bfd.c (bfd_get_sign_extend_vma): Add cases for pe-arm-little
and pei-arm-little.
* coff-arm.c (coff_arm_rtype_to_howto) [COFF_WITH_PE]: Handle
ARM_SECREL.
(coff_arm_reloc_type_lookup): Map BFD_RELOC_32_SECREL to
ARM_SECREL.
* pe-arm.c [COFF_SECTION_ALIGNMENT_ENTRIES]: Define.
* pei-arm.c [TARGET_UNDERSCORE]: Define for ARM_WINCE like in
pe-arm.c.
[COFF_SECTION_ALIGNMENT_ENTRIES]: Define.
---
gas/ChangeLog
2006-08-05 Pedro Alves <pedro_alves@portugalmail.pt>
* config/tc-arm.c: Move "dwarf2dbg.h" inclusion out of OBJ_ELF
only block.
(pe_directive_secrel) [TE_PE]: New function.
(md_pseudo_table) [!OBJ_ELF]: Handle 2byte, 4byte, 8byte, file,
loc, loc_mark_labels.
[TE_PE]: Handle secrel32.
(output_relax_insn): Remove OBJ_ELF around dwarf2_emit_insn
call.
(output_inst): Remove OBJ_ELF around dwarf2_emit_insn call.
(arm_frob_label): Remove OBJ_ELF around dwarf2_emit_label call.
(md_section_align): Only round section sizes here for AOUT
targets.
(tc_arm_regname_to_dw2regnum): Move out for OBJ_ELF only block.
(tc_pe_dwarf2_emit_offset): New function.
(md_apply_fix) [TE_PE]: Handle BFD_RELOC_32_SECREL.
(cons_fix_new_arm): Handle O_secrel.
* config/tc-arm.h : Move DWARF2_LINE_MIN_INSN_LENGTH,
DWARF2_DEFAULT_RETURN_COLUMN and DWARF2_CIE_DATA_ALIGNMENT out
of OBJ_ELF only block.
[TE_PE]: Define O_secrel, TC_DWARF2_EMIT_OFFSET, and declare
tc_pe_dwarf2_emit_offset.
---
ld/testsuite
2006-08-05 Pedro Alves <pedro_alves@portugalmail.pt>
* ld-pe/pe.exp: Enable tests on arm-wince-pe.
* ld-pe/secrel.d: Adjust test to work on arm-wince-pe too.
[-- Attachment #2: gas-dwarf.diff --]
[-- Type: text/plain, Size: 7135 bytes --]
Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.282
diff -u -p -r1.282 tc-arm.c
--- config/tc-arm.c 3 Aug 2006 15:58:59 -0000 1.282
+++ config/tc-arm.c 5 Aug 2006 00:10:43 -0000
@@ -37,10 +37,11 @@
#ifdef OBJ_ELF
#include "elf/arm.h"
-#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#endif
+#include "dwarf2dbg.h"
+
/* XXX Set this to 1 after the next binutils release. */
#define WARN_DEPRECATED 0
@@ -3878,6 +3879,32 @@ static void s_arm_arch (int);
static void s_arm_cpu (int);
static void s_arm_fpu (int);
+#ifdef TE_PE
+static void pe_directive_secrel PARAMS ((int));
+
+static void
+pe_directive_secrel (dummy)
+int dummy ATTRIBUTE_UNUSED;
+{
+ expressionS exp;
+
+ do
+ {
+ expression (&exp);
+ if (exp.X_op == O_symbol)
+ exp.X_op = O_secrel;
+
+ emit_expr (&exp, 4);
+ }
+ while (*input_line_pointer++ == ',');
+
+ input_line_pointer--;
+ demand_empty_rest_of_line ();
+}
+#endif
+
+
+
/* This table describes all the machine specific pseudo-ops the assembler
has to support. The fields are:
pseudo-op name without dot
@@ -3926,10 +3953,22 @@ const pseudo_typeS md_pseudo_table[] =
{ "eabi_attribute", s_arm_eabi_attribute, 0 },
#else
{ "word", cons, 4},
+
+ /* These are used for dwarf. */
+ {"2byte", cons, 2},
+ {"4byte", cons, 4},
+ {"8byte", cons, 8},
+ /* These are used for dwarf2. */
+ { "file", (void (*) (int)) dwarf2_directive_file, 0 },
+ { "loc", dwarf2_directive_loc, 0 },
+ { "loc_mark_labels", dwarf2_directive_loc_mark_labels, 0 },
#endif
{ "extend", float_cons, 'x' },
{ "ldouble", float_cons, 'x' },
{ "packed", float_cons, 'p' },
+#ifdef TE_PE
+ {"secrel32", pe_directive_secrel, 0},
+#endif
{ 0, 0, 0 }
};
\f
@@ -13381,11 +13420,9 @@ output_relax_insn (void)
symbolS *sym;
int offset;
-#ifdef OBJ_ELF
/* The size of the instruction is unknown, so tie the debug info to the
start of the instruction. */
dwarf2_emit_insn (0);
-#endif
switch (inst.reloc.exp.X_op)
{
@@ -13453,9 +13490,7 @@ output_inst (const char * str)
inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
inst.reloc.type);
-#ifdef OBJ_ELF
dwarf2_emit_insn (inst.size);
-#endif
}
/* Tag values used in struct asm_opcode's tag field. */
@@ -13906,9 +13941,7 @@ arm_frob_label (symbolS * sym)
label_is_thumb_function_name = FALSE;
}
-#ifdef OBJ_ELF
dwarf2_emit_label (sym);
-#endif
}
int
@@ -16379,12 +16412,23 @@ valueT
md_section_align (segT segment ATTRIBUTE_UNUSED,
valueT size)
{
-#ifdef OBJ_ELF
- return size;
-#else
- /* Round all sects to multiple of 4. */
- return (size + 3) & ~3;
+#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
+ if (OUTPUT_FLAVOR == bfd_target_aout_flavour)
+ {
+ printf ("OUTPUT_FLAVOR == bfd_target_aout_flavour\n");
+ /* For a.out, force the section size to be aligned. If we don't do
+ this, BFD will align it for us, but it will not write out the
+ final bytes of the section. This may be a bug in BFD, but it is
+ easier to fix it here since that is how the other a.out targets
+ work. */
+ int align;
+
+ align = bfd_get_section_alignment (stdoutput, segment);
+ size = ((size + (1 << align) - 1) & ((valueT) -1 << align));
+ }
#endif
+
+ return size;
}
/* This is called from HANDLE_ALIGN in write.c. Fill in the contents
@@ -16884,6 +16928,16 @@ create_unwind_entry (int have_data)
return 0;
}
+
+/* Initialize the DWARF-2 unwind information for this procedure. */
+
+void
+tc_arm_frame_initial_instructions (void)
+{
+ cfi_add_CFA_def_cfa (REG_SP, 0);
+}
+#endif /* OBJ_ELF */
+
/* Convert REGNAME to a DWARF-2 register number. */
int
@@ -16897,15 +16951,18 @@ tc_arm_regname_to_dw2regnum (char *regna
return reg;
}
-/* Initialize the DWARF-2 unwind information for this procedure. */
-
+#ifdef TE_PE
void
-tc_arm_frame_initial_instructions (void)
+tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
{
- cfi_add_CFA_def_cfa (REG_SP, 0);
-}
-#endif /* OBJ_ELF */
+ expressionS expr;
+ expr.X_op = O_secrel;
+ expr.X_add_symbol = symbol;
+ expr.X_add_number = 0;
+ emit_expr (&expr, size);
+}
+#endif
/* MD interface: Symbol and relocation handling. */
@@ -17897,8 +17954,11 @@ md_apply_fix (fixS * fixP,
case BFD_RELOC_ARM_ROSEGREL32:
case BFD_RELOC_ARM_SBREL32:
case BFD_RELOC_32_PCREL:
- if (fixP->fx_done || !seg->use_rela_p)
-#ifdef TE_WINCE
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
+ if (fixP->fx_done || !seg->use_rela_p)
+#ifdef TE_WINCE
/* For WinCE we only do this for pcrel fixups. */
if (fixP->fx_done || fixP->fx_pcrel)
#endif
@@ -18435,6 +18495,9 @@ tc_gen_reloc (asection *section, fixS *f
case BFD_RELOC_THUMB_PCREL_BLX:
case BFD_RELOC_VTABLE_ENTRY:
case BFD_RELOC_VTABLE_INHERIT:
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
code = fixp->fx_r_type;
break;
@@ -18617,6 +18680,14 @@ cons_fix_new_arm (fragS * frag,
break;
}
+#ifdef TE_PE
+ if (exp->X_op == O_secrel)
+ {
+ exp->X_op = O_symbol;
+ type = BFD_RELOC_32_SECREL;
+ }
+#endif
+
fix_new_exp (frag, where, (int) size, exp, pcrel, type);
}
Index: config/tc-arm.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.h,v
retrieving revision 1.38
diff -u -p -r1.38 tc-arm.h
--- config/tc-arm.h 19 May 2006 11:26:11 -0000 1.38
+++ config/tc-arm.h 5 Aug 2006 00:10:43 -0000
@@ -175,8 +175,15 @@ extern void arm_md_end (void);
goto LABEL; \
}
+#define DWARF2_LINE_MIN_INSN_LENGTH 2
+
+/* The lr register is r14. */
+#define DWARF2_DEFAULT_RETURN_COLUMN 14
+
+/* Registers are generally saved at negative offsets to the CFA. */
+#define DWARF2_CIE_DATA_ALIGNMENT -4
+
#ifdef OBJ_ELF
-# define DWARF2_LINE_MIN_INSN_LENGTH 2
# define obj_frob_symbol(sym, punt) armelf_frob_symbol ((sym), & (punt))
# define md_elf_section_change_hook() arm_elf_change_section ()
# define md_elf_section_type(str, len) arm_elf_section_type (str, len)
@@ -200,12 +207,6 @@ struct arm_segment_info_type
/* We want .cfi_* pseudo-ops for generating unwind info. */
#define TARGET_USE_CFIPOP 1
-/* The lr register is r14. */
-#define DWARF2_DEFAULT_RETURN_COLUMN 14
-
-/* Registers are generally saved at negative offsets to the CFA. */
-#define DWARF2_CIE_DATA_ALIGNMENT -4
-
/* CFI hooks. */
#define tc_regname_to_dw2regnum tc_arm_regname_to_dw2regnum
#define tc_cfi_frame_initial_instructions tc_arm_frame_initial_instructions
@@ -246,3 +247,12 @@ extern bfd_boolean arm_fix_adjustable (s
extern int arm_elf_section_type (const char *, size_t);
extern int tc_arm_regname_to_dw2regnum (char *regname);
extern void tc_arm_frame_initial_instructions (void);
+
+#ifdef TE_PE
+
+#define O_secrel O_md1
+
+#define TC_DWARF2_EMIT_OFFSET tc_pe_dwarf2_emit_offset
+void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
+
+#endif /* TE_PE */
[-- Attachment #3: ld-dwarf.diff --]
[-- Type: text/plain, Size: 3791 bytes --]
Index: testsuite/ld-pe/pe.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/pe.exp,v
retrieving revision 1.2
diff -u -p -r1.2 pe.exp
--- testsuite/ld-pe/pe.exp 12 May 2005 07:32:07 -0000 1.2
+++ testsuite/ld-pe/pe.exp 4 Aug 2006 23:25:44 -0000
@@ -17,9 +17,9 @@
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#
-# This test can only be run on i386 PE/COFF platforms.
+# This test can only be run on PE/COFF platforms that support .secrel32.
if { ![istarget i*86-*-cygwin*] && ![istarget i*86-*-pe]
- && ![istarget i*86-*-mingw*] } {
+ && ![istarget i*86-*-mingw*] && ![istarget arm-wince-pe] } {
return
}
Index: testsuite/ld-pe/secrel.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/secrel.d,v
retrieving revision 1.2
diff -u -p -r1.2 secrel.d
--- testsuite/ld-pe/secrel.d 29 Sep 2004 13:36:22 -0000 1.2
+++ testsuite/ld-pe/secrel.d 4 Aug 2006 23:25:45 -0000
@@ -1,27 +1,27 @@
-tmpdir/secrel\.x: file format pei-i386
+tmpdir/secrel\.x: +file format pei-.*
Contents of section \.text:
- 401000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 401010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 401020 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 401030 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 401040 ........ ........ ........ ........ ................
+ .*1000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*1010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*1020 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*1030 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*1040 ........ ........ ........ ........ ................
Contents of section \.data:
- 402000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 402010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 402020 3e3e3e3e 04000000 110d0000 00111600 >>>>............
- 402030 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
- 402040 3e3e3e3e 04000000 110d0000 00111600 >>>>............
- 402050 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
- 402060 3e3e3e3e 04000000 110d0000 00111600 >>>>............
- 402070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
- 402080 3e3e3e3e 24000000 112d0000 00113600 >>>>\$....-....6.
- 402090 0000113f 00000011 3c3c3c3c 3c3c3c3c ...\?....<<<<<<<<
+ .*2000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*2010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*2020 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ .*2030 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ .*2040 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ .*2050 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ .*2060 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ .*2070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ .*2080 3e3e3e3e 24000000 112d0000 00113600 >>>>\$....-....6.
+ .*2090 0000113f 00000011 3c3c3c3c 3c3c3c3c ...\?....<<<<<<<<
Contents of section \.rdata:
- 403000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 403010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 403020 3e3e3e3e 00000000 00000000 00000000 >>>>............
+ .*3000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*3010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*3020 3e3e3e3e 00000000 00000000 00000000 >>>>............
Contents of section \.idata:
- 404000 00000000 00000000 00000000 00000000 ................
- 404010 00000000 ....
+ .*4000 00000000 00000000 00000000 00000000 ................
+ .*4010 00000000 ....
[-- Attachment #4: bfd-dwarf.diff --]
[-- Type: text/plain, Size: 4912 bytes --]
Index: bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.85
diff -u -p -r1.85 bfd.c
--- bfd.c 20 Jun 2006 09:58:36 -0000 1.85
+++ bfd.c 4 Aug 2006 23:17:55 -0000
@@ -883,7 +883,9 @@ bfd_get_sign_extend_vma (bfd *abfd)
a place will have to be found. Until then, this hack will do. */
if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
|| strcmp (name, "pe-i386") == 0
- || strcmp (name, "pei-i386") == 0)
+ || strcmp (name, "pei-i386") == 0
+ || strcmp (name, "pe-arm-little") == 0
+ || strcmp (name, "pei-arm-little") == 0)
return 1;
bfd_set_error (bfd_error_wrong_format);
Index: coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.65
diff -u -p -r1.65 coff-arm.c
--- coff-arm.c 1 Jun 2006 03:45:58 -0000 1.65
+++ coff-arm.c 4 Aug 2006 23:17:58 -0000
@@ -539,6 +539,32 @@ coff_arm_rtype_to_howto (bfd *abfd ATTRI
if (rel->r_type == ARM_RVA32)
*addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase;
+#ifdef COFF_WITH_PE
+ if (rel->r_type == ARM_SECREL)
+ {
+ bfd_vma osect_vma;
+
+ if (h && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak))
+ osect_vma = h->root.u.def.section->output_section->vma;
+ else
+ {
+ asection *sec;
+ int i;
+
+ /* Sigh, the only way to get the section to offset against
+ is to find it the hard way. */
+
+ for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
+ sec = sec->next;
+
+ osect_vma = sec->output_section->vma;
+ }
+
+ *addendp -= osect_vma;
+ }
+#endif
+
return howto;
}
@@ -808,6 +834,7 @@ coff_arm_reloc_type_lookup (bfd * abfd,
ASTD (BFD_RELOC_RVA, ARM_RVA32);
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, ARM_26);
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH12, ARM_THUMB12);
+ ASTD (BFD_RELOC_32_SECREL, ARM_SECREL);
#else
ASTD (BFD_RELOC_8, ARM_8);
ASTD (BFD_RELOC_16, ARM_16);
Index: pe-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/pe-arm.c,v
retrieving revision 1.9
diff -u -p -r1.9 pe-arm.c
--- pe-arm.c 4 May 2005 15:53:37 -0000 1.9
+++ pe-arm.c 4 Aug 2006 23:17:59 -0000
@@ -44,4 +44,22 @@ Foundation, Inc., 51 Franklin Street - F
#define TARGET_UNDERSCORE 0
#endif
+#define COFF_SECTION_ALIGNMENT_ENTRIES \
+{ COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".rdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
+
#include "coff-arm.c"
Index: pei-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-arm.c,v
retrieving revision 1.9
diff -u -p -r1.9 pei-arm.c
--- pei-arm.c 4 May 2005 15:53:37 -0000 1.9
+++ pei-arm.c 4 Aug 2006 23:17:59 -0000
@@ -32,4 +32,26 @@ Foundation, Inc., 51 Franklin Street - F
#define PCRELOFFSET TRUE
#define COFF_LONG_SECTION_NAMES
+#ifdef ARM_WINCE
+# define TARGET_UNDERSCORE 0
+#endif
+
+#define COFF_SECTION_ALIGNMENT_ENTRIES \
+{ COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".rdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
+
#include "coff-arm.c"
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-05 0:39 [PATCH]: Add DWARF debugging format support for arm-wince-pe Pedro Alves
@ 2006-08-05 3:20 ` Daniel Jacobowitz
2006-08-05 12:17 ` Pedro Alves
2006-08-05 6:57 ` Andreas Schwab
1 sibling, 1 reply; 10+ messages in thread
From: Daniel Jacobowitz @ 2006-08-05 3:20 UTC (permalink / raw)
To: Pedro Alves; +Cc: binutils
On Sat, Aug 05, 2006 at 01:39:26AM +0100, Pedro Alves wrote:
> I don't know which is the correct value to return in
> bfd_get_sign_extend_vma. I tested it with 1 and 0, but found no
> difference.
> What is the correct value? How does one test for it?
For a pure 32-bit architecture, it doesn't really matter. But in
general 0 is correct.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-05 0:39 [PATCH]: Add DWARF debugging format support for arm-wince-pe Pedro Alves
2006-08-05 3:20 ` Daniel Jacobowitz
@ 2006-08-05 6:57 ` Andreas Schwab
2006-08-05 12:18 ` Pedro Alves
1 sibling, 1 reply; 10+ messages in thread
From: Andreas Schwab @ 2006-08-05 6:57 UTC (permalink / raw)
To: Pedro Alves; +Cc: binutils
Pedro Alves <pedro_alves@portugalmail.pt> writes:
> @@ -16379,12 +16412,23 @@ valueT
> md_section_align (segT segment ATTRIBUTE_UNUSED,
> valueT size)
> {
> -#ifdef OBJ_ELF
> - return size;
> -#else
> - /* Round all sects to multiple of 4. */
> - return (size + 3) & ~3;
> +#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
> + if (OUTPUT_FLAVOR == bfd_target_aout_flavour)
> + {
> + printf ("OUTPUT_FLAVOR == bfd_target_aout_flavour\n");
Leftover debug output?
Andreas.
--
Andreas Schwab, SuSE Labs, schwab@suse.de
SuSE Linux Products GmbH, MaxfeldstraÃe 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756 01D3 44D5 214B 8276 4ED5
"And now for something completely different."
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-05 3:20 ` Daniel Jacobowitz
@ 2006-08-05 12:17 ` Pedro Alves
2006-08-05 18:46 ` Daniel Jacobowitz
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2006-08-05 12:17 UTC (permalink / raw)
To: binutils
Daniel Jacobowitz wrote:
> On Sat, Aug 05, 2006 at 01:39:26AM +0100, Pedro Alves wrote:
>> I don't know which is the correct value to return in
>> bfd_get_sign_extend_vma. I tested it with 1 and 0, but found no
>> difference.
>> What is the correct value? How does one test for it?
>
> For a pure 32-bit architecture, it doesn't really matter. But in
> general 0 is correct.
>
Ok. Than should I 'else if' ?:
if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
|| strcmp (name, "pe-i386") == 0
|| strcmp (name, "pei-i386") == 0)
return 1;
else if (strcmp (name, "pe-arm-little") == 0
|| strcmp (name, "pei-arm-little") == 0)
return 0;
or, should i386 return 0 too ?:
if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
|| strcmp (name, "pe-i386") == 0
|| strcmp (name, "pei-i386") == 0
|| strcmp (name, "pe-arm-little") == 0
|| strcmp (name, "pei-arm-little") == 0)
return 0;
or, simply leave i386 and arm returning 1, until this hack
is cleaned up?
Cheers,
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-05 6:57 ` Andreas Schwab
@ 2006-08-05 12:18 ` Pedro Alves
2006-08-06 14:15 ` Nick Clifton
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2006-08-05 12:18 UTC (permalink / raw)
To: Andreas Schwab; +Cc: binutils
[-- Attachment #1: Type: text/plain, Size: 616 bytes --]
Andreas Schwab wrote:
> Pedro Alves <pedro_alves@portugalmail.pt> writes:
>
>> @@ -16379,12 +16412,23 @@ valueT
>> md_section_align (segT segment ATTRIBUTE_UNUSED,
>> valueT size)
>> {
>> -#ifdef OBJ_ELF
>> - return size;
>> -#else
>> - /* Round all sects to multiple of 4. */
>> - return (size + 3) & ~3;
>> +#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
>> + if (OUTPUT_FLAVOR == bfd_target_aout_flavour)
>> + {
>> + printf ("OUTPUT_FLAVOR == bfd_target_aout_flavour\n");
>
> Leftover debug output?
>
Ooops, thanks for noticing.
Updated patch for gas attached.
Cheers,
Pedro Alves
[-- Attachment #2: gas-dwarf.diff --]
[-- Type: text/plain, Size: 7073 bytes --]
Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.282
diff -u -p -r1.282 tc-arm.c
--- config/tc-arm.c 3 Aug 2006 15:58:59 -0000 1.282
+++ config/tc-arm.c 5 Aug 2006 10:27:51 -0000
@@ -37,10 +37,11 @@
#ifdef OBJ_ELF
#include "elf/arm.h"
-#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#endif
+#include "dwarf2dbg.h"
+
/* XXX Set this to 1 after the next binutils release. */
#define WARN_DEPRECATED 0
@@ -3878,6 +3879,32 @@ static void s_arm_arch (int);
static void s_arm_cpu (int);
static void s_arm_fpu (int);
+#ifdef TE_PE
+static void pe_directive_secrel PARAMS ((int));
+
+static void
+pe_directive_secrel (dummy)
+int dummy ATTRIBUTE_UNUSED;
+{
+ expressionS exp;
+
+ do
+ {
+ expression (&exp);
+ if (exp.X_op == O_symbol)
+ exp.X_op = O_secrel;
+
+ emit_expr (&exp, 4);
+ }
+ while (*input_line_pointer++ == ',');
+
+ input_line_pointer--;
+ demand_empty_rest_of_line ();
+}
+#endif
+
+
+
/* This table describes all the machine specific pseudo-ops the assembler
has to support. The fields are:
pseudo-op name without dot
@@ -3926,10 +3953,22 @@ const pseudo_typeS md_pseudo_table[] =
{ "eabi_attribute", s_arm_eabi_attribute, 0 },
#else
{ "word", cons, 4},
+
+ /* These are used for dwarf. */
+ {"2byte", cons, 2},
+ {"4byte", cons, 4},
+ {"8byte", cons, 8},
+ /* These are used for dwarf2. */
+ { "file", (void (*) (int)) dwarf2_directive_file, 0 },
+ { "loc", dwarf2_directive_loc, 0 },
+ { "loc_mark_labels", dwarf2_directive_loc_mark_labels, 0 },
#endif
{ "extend", float_cons, 'x' },
{ "ldouble", float_cons, 'x' },
{ "packed", float_cons, 'p' },
+#ifdef TE_PE
+ {"secrel32", pe_directive_secrel, 0},
+#endif
{ 0, 0, 0 }
};
\f
@@ -13381,11 +13420,9 @@ output_relax_insn (void)
symbolS *sym;
int offset;
-#ifdef OBJ_ELF
/* The size of the instruction is unknown, so tie the debug info to the
start of the instruction. */
dwarf2_emit_insn (0);
-#endif
switch (inst.reloc.exp.X_op)
{
@@ -13453,9 +13490,7 @@ output_inst (const char * str)
inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
inst.reloc.type);
-#ifdef OBJ_ELF
dwarf2_emit_insn (inst.size);
-#endif
}
/* Tag values used in struct asm_opcode's tag field. */
@@ -13906,9 +13941,7 @@ arm_frob_label (symbolS * sym)
label_is_thumb_function_name = FALSE;
}
-#ifdef OBJ_ELF
dwarf2_emit_label (sym);
-#endif
}
int
@@ -16379,12 +16412,22 @@ valueT
md_section_align (segT segment ATTRIBUTE_UNUSED,
valueT size)
{
-#ifdef OBJ_ELF
- return size;
-#else
- /* Round all sects to multiple of 4. */
- return (size + 3) & ~3;
+#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
+ if (OUTPUT_FLAVOR == bfd_target_aout_flavour)
+ {
+ /* For a.out, force the section size to be aligned. If we don't do
+ this, BFD will align it for us, but it will not write out the
+ final bytes of the section. This may be a bug in BFD, but it is
+ easier to fix it here since that is how the other a.out targets
+ work. */
+ int align;
+
+ align = bfd_get_section_alignment (stdoutput, segment);
+ size = ((size + (1 << align) - 1) & ((valueT) -1 << align));
+ }
#endif
+
+ return size;
}
/* This is called from HANDLE_ALIGN in write.c. Fill in the contents
@@ -16884,6 +16927,16 @@ create_unwind_entry (int have_data)
return 0;
}
+
+/* Initialize the DWARF-2 unwind information for this procedure. */
+
+void
+tc_arm_frame_initial_instructions (void)
+{
+ cfi_add_CFA_def_cfa (REG_SP, 0);
+}
+#endif /* OBJ_ELF */
+
/* Convert REGNAME to a DWARF-2 register number. */
int
@@ -16897,15 +16950,18 @@ tc_arm_regname_to_dw2regnum (char *regna
return reg;
}
-/* Initialize the DWARF-2 unwind information for this procedure. */
-
+#ifdef TE_PE
void
-tc_arm_frame_initial_instructions (void)
+tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
{
- cfi_add_CFA_def_cfa (REG_SP, 0);
-}
-#endif /* OBJ_ELF */
+ expressionS expr;
+ expr.X_op = O_secrel;
+ expr.X_add_symbol = symbol;
+ expr.X_add_number = 0;
+ emit_expr (&expr, size);
+}
+#endif
/* MD interface: Symbol and relocation handling. */
@@ -17897,8 +17953,11 @@ md_apply_fix (fixS * fixP,
case BFD_RELOC_ARM_ROSEGREL32:
case BFD_RELOC_ARM_SBREL32:
case BFD_RELOC_32_PCREL:
- if (fixP->fx_done || !seg->use_rela_p)
-#ifdef TE_WINCE
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
+ if (fixP->fx_done || !seg->use_rela_p)
+#ifdef TE_WINCE
/* For WinCE we only do this for pcrel fixups. */
if (fixP->fx_done || fixP->fx_pcrel)
#endif
@@ -18435,6 +18494,9 @@ tc_gen_reloc (asection *section, fixS *f
case BFD_RELOC_THUMB_PCREL_BLX:
case BFD_RELOC_VTABLE_ENTRY:
case BFD_RELOC_VTABLE_INHERIT:
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
code = fixp->fx_r_type;
break;
@@ -18617,6 +18679,14 @@ cons_fix_new_arm (fragS * frag,
break;
}
+#ifdef TE_PE
+ if (exp->X_op == O_secrel)
+ {
+ exp->X_op = O_symbol;
+ type = BFD_RELOC_32_SECREL;
+ }
+#endif
+
fix_new_exp (frag, where, (int) size, exp, pcrel, type);
}
Index: config/tc-arm.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.h,v
retrieving revision 1.38
diff -u -p -r1.38 tc-arm.h
--- config/tc-arm.h 19 May 2006 11:26:11 -0000 1.38
+++ config/tc-arm.h 5 Aug 2006 10:27:54 -0000
@@ -175,8 +175,15 @@ extern void arm_md_end (void);
goto LABEL; \
}
+#define DWARF2_LINE_MIN_INSN_LENGTH 2
+
+/* The lr register is r14. */
+#define DWARF2_DEFAULT_RETURN_COLUMN 14
+
+/* Registers are generally saved at negative offsets to the CFA. */
+#define DWARF2_CIE_DATA_ALIGNMENT -4
+
#ifdef OBJ_ELF
-# define DWARF2_LINE_MIN_INSN_LENGTH 2
# define obj_frob_symbol(sym, punt) armelf_frob_symbol ((sym), & (punt))
# define md_elf_section_change_hook() arm_elf_change_section ()
# define md_elf_section_type(str, len) arm_elf_section_type (str, len)
@@ -200,12 +207,6 @@ struct arm_segment_info_type
/* We want .cfi_* pseudo-ops for generating unwind info. */
#define TARGET_USE_CFIPOP 1
-/* The lr register is r14. */
-#define DWARF2_DEFAULT_RETURN_COLUMN 14
-
-/* Registers are generally saved at negative offsets to the CFA. */
-#define DWARF2_CIE_DATA_ALIGNMENT -4
-
/* CFI hooks. */
#define tc_regname_to_dw2regnum tc_arm_regname_to_dw2regnum
#define tc_cfi_frame_initial_instructions tc_arm_frame_initial_instructions
@@ -246,3 +247,12 @@ extern bfd_boolean arm_fix_adjustable (s
extern int arm_elf_section_type (const char *, size_t);
extern int tc_arm_regname_to_dw2regnum (char *regname);
extern void tc_arm_frame_initial_instructions (void);
+
+#ifdef TE_PE
+
+#define O_secrel O_md1
+
+#define TC_DWARF2_EMIT_OFFSET tc_pe_dwarf2_emit_offset
+void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
+
+#endif /* TE_PE */
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-05 12:17 ` Pedro Alves
@ 2006-08-05 18:46 ` Daniel Jacobowitz
0 siblings, 0 replies; 10+ messages in thread
From: Daniel Jacobowitz @ 2006-08-05 18:46 UTC (permalink / raw)
To: Pedro Alves; +Cc: binutils
On Sat, Aug 05, 2006 at 01:17:47PM +0100, Pedro Alves wrote:
> Ok. Than should I 'else if' ?:
>
> if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
> || strcmp (name, "pe-i386") == 0
> || strcmp (name, "pei-i386") == 0)
> return 1;
> else if (strcmp (name, "pe-arm-little") == 0
> || strcmp (name, "pei-arm-little") == 0)
> return 0;
>
> or, should i386 return 0 too ?:
>
> if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
> || strcmp (name, "pe-i386") == 0
> || strcmp (name, "pei-i386") == 0
> || strcmp (name, "pe-arm-little") == 0
> || strcmp (name, "pei-arm-little") == 0)
> return 0;
>
>
> or, simply leave i386 and arm returning 1, until this hack
> is cleaned up?
I'd do the last option.
--
Daniel Jacobowitz
CodeSourcery
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-05 12:18 ` Pedro Alves
@ 2006-08-06 14:15 ` Nick Clifton
2006-08-06 14:41 ` Pedro Alves
0 siblings, 1 reply; 10+ messages in thread
From: Nick Clifton @ 2006-08-06 14:15 UTC (permalink / raw)
To: Pedro Alves; +Cc: Andreas Schwab, binutils
Hi Pedro,
> Updated patch for gas attached.
There are still a few minor problems with this part of the patch:
> +#ifdef TE_PE
> +static void pe_directive_secrel PARAMS ((int));
There is no need for this declaration, it is redundant. Plus we are not
using the PARAMS macro any more.
> +static void
> +pe_directive_secrel (dummy)
> +int dummy ATTRIBUTE_UNUSED;
We are following the ISO-C90 standard now, so the type qualifiers for
function arguments should be included in the declaration, ie:
pe_directive_secrel (int dummy ATTRIBUTE_UNUSED)
With these two changes the entire patch is approved.
Cheers
Nick
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-06 14:15 ` Nick Clifton
@ 2006-08-06 14:41 ` Pedro Alves
2006-08-06 14:45 ` Nick Clifton
0 siblings, 1 reply; 10+ messages in thread
From: Pedro Alves @ 2006-08-06 14:41 UTC (permalink / raw)
To: Nick Clifton; +Cc: Andreas Schwab, binutils
[-- Attachment #1: Type: text/plain, Size: 2921 bytes --]
Nick Clifton wrote:
> Hi Pedro,
>
>> Updated patch for gas attached.
>
> There are still a few minor problems with this part of the patch:
>
>> +#ifdef TE_PE
>> +static void pe_directive_secrel PARAMS ((int));
>
> There is no need for this declaration, it is redundant. Plus we are not
> using the PARAMS macro any more.
>
>> +static void
>> +pe_directive_secrel (dummy)
>> +int dummy ATTRIBUTE_UNUSED;
>
> We are following the ISO-C90 standard now, so the type qualifiers for
> function arguments should be included in the declaration, ie:
>
> pe_directive_secrel (int dummy ATTRIBUTE_UNUSED)
>
>
> With these two changes the entire patch is approved.
>
Thanks.
Attached is the updated gas patch with Nick's requested changes, and
also the previous bfd and ld testsuite patches.
Nick, just to be sure, with "entire patch", you mean bfd+gas+ld, or just
gas?
Also, since I don't have commit privileges, could someone else (Nick?)
please commit them?
(Same for:
http://sourceware.org/ml/binutils/2006-08/msg00057.html
http://sourceware.org/ml/binutils/2006-08/msg00056.html)
Cheers,
Pedro Alves
----
bfd/ChangeLog
2006-08-05 Pedro Alves <pedro_alves@portugalmail.pt>
* bfd.c (bfd_get_sign_extend_vma): Add cases for pe-arm-little
and pei-arm-little.
* coff-arm.c (coff_arm_rtype_to_howto) [COFF_WITH_PE]: Handle
ARM_SECREL.
(coff_arm_reloc_type_lookup): Map BFD_RELOC_32_SECREL to
ARM_SECREL.
* pe-arm.c [COFF_SECTION_ALIGNMENT_ENTRIES]: Define.
* pei-arm.c [TARGET_UNDERSCORE]: Define for ARM_WINCE like in
pe-arm.c.
[COFF_SECTION_ALIGNMENT_ENTRIES]: Define.
---
gas/ChangeLog
2006-08-05 Pedro Alves <pedro_alves@portugalmail.pt>
* config/tc-arm.c: Move "dwarf2dbg.h" inclusion out of OBJ_ELF
only block.
(pe_directive_secrel) [TE_PE]: New function.
(md_pseudo_table) [!OBJ_ELF]: Handle 2byte, 4byte, 8byte, file,
loc, loc_mark_labels.
[TE_PE]: Handle secrel32.
(output_relax_insn): Remove OBJ_ELF around dwarf2_emit_insn
call.
(output_inst): Remove OBJ_ELF around dwarf2_emit_insn call.
(arm_frob_label): Remove OBJ_ELF around dwarf2_emit_label call.
(md_section_align): Only round section sizes here for AOUT
targets.
(tc_arm_regname_to_dw2regnum): Move out for OBJ_ELF only block.
(tc_pe_dwarf2_emit_offset): New function.
(md_apply_fix) [TE_PE]: Handle BFD_RELOC_32_SECREL.
(cons_fix_new_arm): Handle O_secrel.
* config/tc-arm.h : Move DWARF2_LINE_MIN_INSN_LENGTH,
DWARF2_DEFAULT_RETURN_COLUMN and DWARF2_CIE_DATA_ALIGNMENT out
of OBJ_ELF only block.
[TE_PE]: Define O_secrel, TC_DWARF2_EMIT_OFFSET, and declare
tc_pe_dwarf2_emit_offset.
---
ld/testsuite
2006-08-05 Pedro Alves <pedro_alves@portugalmail.pt>
* ld-pe/pe.exp: Enable tests on arm-wince-pe.
* ld-pe/secrel.d: Adjust test to work on arm-wince-pe too.
[-- Attachment #2: gas-dwarf.diff --]
[-- Type: text/plain, Size: 7017 bytes --]
Index: config/tc-arm.c
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.c,v
retrieving revision 1.282
diff -u -p -r1.282 tc-arm.c
--- config/tc-arm.c 3 Aug 2006 15:58:59 -0000 1.282
+++ config/tc-arm.c 6 Aug 2006 14:25:18 -0000
@@ -37,10 +37,11 @@
#ifdef OBJ_ELF
#include "elf/arm.h"
-#include "dwarf2dbg.h"
#include "dw2gencfi.h"
#endif
+#include "dwarf2dbg.h"
+
/* XXX Set this to 1 after the next binutils release. */
#define WARN_DEPRECATED 0
@@ -3878,6 +3879,30 @@ static void s_arm_arch (int);
static void s_arm_cpu (int);
static void s_arm_fpu (int);
+#ifdef TE_PE
+
+static void
+pe_directive_secrel (int dummy ATTRIBUTE_UNUSED)
+{
+ expressionS exp;
+
+ do
+ {
+ expression (&exp);
+ if (exp.X_op == O_symbol)
+ exp.X_op = O_secrel;
+
+ emit_expr (&exp, 4);
+ }
+ while (*input_line_pointer++ == ',');
+
+ input_line_pointer--;
+ demand_empty_rest_of_line ();
+}
+#endif
+
+
+
/* This table describes all the machine specific pseudo-ops the assembler
has to support. The fields are:
pseudo-op name without dot
@@ -3926,10 +3951,22 @@ const pseudo_typeS md_pseudo_table[] =
{ "eabi_attribute", s_arm_eabi_attribute, 0 },
#else
{ "word", cons, 4},
+
+ /* These are used for dwarf. */
+ {"2byte", cons, 2},
+ {"4byte", cons, 4},
+ {"8byte", cons, 8},
+ /* These are used for dwarf2. */
+ { "file", (void (*) (int)) dwarf2_directive_file, 0 },
+ { "loc", dwarf2_directive_loc, 0 },
+ { "loc_mark_labels", dwarf2_directive_loc_mark_labels, 0 },
#endif
{ "extend", float_cons, 'x' },
{ "ldouble", float_cons, 'x' },
{ "packed", float_cons, 'p' },
+#ifdef TE_PE
+ {"secrel32", pe_directive_secrel, 0},
+#endif
{ 0, 0, 0 }
};
\f
@@ -13381,11 +13418,9 @@ output_relax_insn (void)
symbolS *sym;
int offset;
-#ifdef OBJ_ELF
/* The size of the instruction is unknown, so tie the debug info to the
start of the instruction. */
dwarf2_emit_insn (0);
-#endif
switch (inst.reloc.exp.X_op)
{
@@ -13453,9 +13488,7 @@ output_inst (const char * str)
inst.size, & inst.reloc.exp, inst.reloc.pc_rel,
inst.reloc.type);
-#ifdef OBJ_ELF
dwarf2_emit_insn (inst.size);
-#endif
}
/* Tag values used in struct asm_opcode's tag field. */
@@ -13906,9 +13939,7 @@ arm_frob_label (symbolS * sym)
label_is_thumb_function_name = FALSE;
}
-#ifdef OBJ_ELF
dwarf2_emit_label (sym);
-#endif
}
int
@@ -16379,12 +16410,22 @@ valueT
md_section_align (segT segment ATTRIBUTE_UNUSED,
valueT size)
{
-#ifdef OBJ_ELF
- return size;
-#else
- /* Round all sects to multiple of 4. */
- return (size + 3) & ~3;
+#if (defined (OBJ_AOUT) || defined (OBJ_MAYBE_AOUT))
+ if (OUTPUT_FLAVOR == bfd_target_aout_flavour)
+ {
+ /* For a.out, force the section size to be aligned. If we don't do
+ this, BFD will align it for us, but it will not write out the
+ final bytes of the section. This may be a bug in BFD, but it is
+ easier to fix it here since that is how the other a.out targets
+ work. */
+ int align;
+
+ align = bfd_get_section_alignment (stdoutput, segment);
+ size = ((size + (1 << align) - 1) & ((valueT) -1 << align));
+ }
#endif
+
+ return size;
}
/* This is called from HANDLE_ALIGN in write.c. Fill in the contents
@@ -16884,6 +16925,16 @@ create_unwind_entry (int have_data)
return 0;
}
+
+/* Initialize the DWARF-2 unwind information for this procedure. */
+
+void
+tc_arm_frame_initial_instructions (void)
+{
+ cfi_add_CFA_def_cfa (REG_SP, 0);
+}
+#endif /* OBJ_ELF */
+
/* Convert REGNAME to a DWARF-2 register number. */
int
@@ -16897,15 +16948,18 @@ tc_arm_regname_to_dw2regnum (char *regna
return reg;
}
-/* Initialize the DWARF-2 unwind information for this procedure. */
-
+#ifdef TE_PE
void
-tc_arm_frame_initial_instructions (void)
+tc_pe_dwarf2_emit_offset (symbolS *symbol, unsigned int size)
{
- cfi_add_CFA_def_cfa (REG_SP, 0);
-}
-#endif /* OBJ_ELF */
+ expressionS expr;
+ expr.X_op = O_secrel;
+ expr.X_add_symbol = symbol;
+ expr.X_add_number = 0;
+ emit_expr (&expr, size);
+}
+#endif
/* MD interface: Symbol and relocation handling. */
@@ -17897,8 +17951,11 @@ md_apply_fix (fixS * fixP,
case BFD_RELOC_ARM_ROSEGREL32:
case BFD_RELOC_ARM_SBREL32:
case BFD_RELOC_32_PCREL:
- if (fixP->fx_done || !seg->use_rela_p)
-#ifdef TE_WINCE
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
+ if (fixP->fx_done || !seg->use_rela_p)
+#ifdef TE_WINCE
/* For WinCE we only do this for pcrel fixups. */
if (fixP->fx_done || fixP->fx_pcrel)
#endif
@@ -18435,6 +18492,9 @@ tc_gen_reloc (asection *section, fixS *f
case BFD_RELOC_THUMB_PCREL_BLX:
case BFD_RELOC_VTABLE_ENTRY:
case BFD_RELOC_VTABLE_INHERIT:
+#ifdef TE_PE
+ case BFD_RELOC_32_SECREL:
+#endif
code = fixp->fx_r_type;
break;
@@ -18617,6 +18677,14 @@ cons_fix_new_arm (fragS * frag,
break;
}
+#ifdef TE_PE
+ if (exp->X_op == O_secrel)
+ {
+ exp->X_op = O_symbol;
+ type = BFD_RELOC_32_SECREL;
+ }
+#endif
+
fix_new_exp (frag, where, (int) size, exp, pcrel, type);
}
Index: config/tc-arm.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-arm.h,v
retrieving revision 1.38
diff -u -p -r1.38 tc-arm.h
--- config/tc-arm.h 19 May 2006 11:26:11 -0000 1.38
+++ config/tc-arm.h 6 Aug 2006 14:25:23 -0000
@@ -175,8 +175,15 @@ extern void arm_md_end (void);
goto LABEL; \
}
+#define DWARF2_LINE_MIN_INSN_LENGTH 2
+
+/* The lr register is r14. */
+#define DWARF2_DEFAULT_RETURN_COLUMN 14
+
+/* Registers are generally saved at negative offsets to the CFA. */
+#define DWARF2_CIE_DATA_ALIGNMENT -4
+
#ifdef OBJ_ELF
-# define DWARF2_LINE_MIN_INSN_LENGTH 2
# define obj_frob_symbol(sym, punt) armelf_frob_symbol ((sym), & (punt))
# define md_elf_section_change_hook() arm_elf_change_section ()
# define md_elf_section_type(str, len) arm_elf_section_type (str, len)
@@ -200,12 +207,6 @@ struct arm_segment_info_type
/* We want .cfi_* pseudo-ops for generating unwind info. */
#define TARGET_USE_CFIPOP 1
-/* The lr register is r14. */
-#define DWARF2_DEFAULT_RETURN_COLUMN 14
-
-/* Registers are generally saved at negative offsets to the CFA. */
-#define DWARF2_CIE_DATA_ALIGNMENT -4
-
/* CFI hooks. */
#define tc_regname_to_dw2regnum tc_arm_regname_to_dw2regnum
#define tc_cfi_frame_initial_instructions tc_arm_frame_initial_instructions
@@ -246,3 +247,12 @@ extern bfd_boolean arm_fix_adjustable (s
extern int arm_elf_section_type (const char *, size_t);
extern int tc_arm_regname_to_dw2regnum (char *regname);
extern void tc_arm_frame_initial_instructions (void);
+
+#ifdef TE_PE
+
+#define O_secrel O_md1
+
+#define TC_DWARF2_EMIT_OFFSET tc_pe_dwarf2_emit_offset
+void tc_pe_dwarf2_emit_offset (symbolS *, unsigned int);
+
+#endif /* TE_PE */
[-- Attachment #3: bfd-dwarf.diff --]
[-- Type: text/plain, Size: 4912 bytes --]
Index: bfd.c
===================================================================
RCS file: /cvs/src/src/bfd/bfd.c,v
retrieving revision 1.85
diff -u -p -r1.85 bfd.c
--- bfd.c 20 Jun 2006 09:58:36 -0000 1.85
+++ bfd.c 4 Aug 2006 23:17:55 -0000
@@ -883,7 +883,9 @@ bfd_get_sign_extend_vma (bfd *abfd)
a place will have to be found. Until then, this hack will do. */
if (strncmp (name, "coff-go32", sizeof ("coff-go32") - 1) == 0
|| strcmp (name, "pe-i386") == 0
- || strcmp (name, "pei-i386") == 0)
+ || strcmp (name, "pei-i386") == 0
+ || strcmp (name, "pe-arm-little") == 0
+ || strcmp (name, "pei-arm-little") == 0)
return 1;
bfd_set_error (bfd_error_wrong_format);
Index: coff-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-arm.c,v
retrieving revision 1.65
diff -u -p -r1.65 coff-arm.c
--- coff-arm.c 1 Jun 2006 03:45:58 -0000 1.65
+++ coff-arm.c 4 Aug 2006 23:17:58 -0000
@@ -539,6 +539,32 @@ coff_arm_rtype_to_howto (bfd *abfd ATTRI
if (rel->r_type == ARM_RVA32)
*addendp -= pe_data (sec->output_section->owner)->pe_opthdr.ImageBase;
+#ifdef COFF_WITH_PE
+ if (rel->r_type == ARM_SECREL)
+ {
+ bfd_vma osect_vma;
+
+ if (h && (h->type == bfd_link_hash_defined
+ || h->type == bfd_link_hash_defweak))
+ osect_vma = h->root.u.def.section->output_section->vma;
+ else
+ {
+ asection *sec;
+ int i;
+
+ /* Sigh, the only way to get the section to offset against
+ is to find it the hard way. */
+
+ for (sec = abfd->sections, i = 1; i < sym->n_scnum; i++)
+ sec = sec->next;
+
+ osect_vma = sec->output_section->vma;
+ }
+
+ *addendp -= osect_vma;
+ }
+#endif
+
return howto;
}
@@ -808,6 +834,7 @@ coff_arm_reloc_type_lookup (bfd * abfd,
ASTD (BFD_RELOC_RVA, ARM_RVA32);
ASTD (BFD_RELOC_ARM_PCREL_BRANCH, ARM_26);
ASTD (BFD_RELOC_THUMB_PCREL_BRANCH12, ARM_THUMB12);
+ ASTD (BFD_RELOC_32_SECREL, ARM_SECREL);
#else
ASTD (BFD_RELOC_8, ARM_8);
ASTD (BFD_RELOC_16, ARM_16);
Index: pe-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/pe-arm.c,v
retrieving revision 1.9
diff -u -p -r1.9 pe-arm.c
--- pe-arm.c 4 May 2005 15:53:37 -0000 1.9
+++ pe-arm.c 4 Aug 2006 23:17:59 -0000
@@ -44,4 +44,22 @@ Foundation, Inc., 51 Franklin Street - F
#define TARGET_UNDERSCORE 0
#endif
+#define COFF_SECTION_ALIGNMENT_ENTRIES \
+{ COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".rdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
+
#include "coff-arm.c"
Index: pei-arm.c
===================================================================
RCS file: /cvs/src/src/bfd/pei-arm.c,v
retrieving revision 1.9
diff -u -p -r1.9 pei-arm.c
--- pei-arm.c 4 May 2005 15:53:37 -0000 1.9
+++ pei-arm.c 4 Aug 2006 23:17:59 -0000
@@ -32,4 +32,26 @@ Foundation, Inc., 51 Franklin Street - F
#define PCRELOFFSET TRUE
#define COFF_LONG_SECTION_NAMES
+#ifdef ARM_WINCE
+# define TARGET_UNDERSCORE 0
+#endif
+
+#define COFF_SECTION_ALIGNMENT_ENTRIES \
+{ COFF_SECTION_NAME_EXACT_MATCH (".bss"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".data"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".rdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".text"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".idata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_EXACT_MATCH (".pdata"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 2 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".debug"), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }, \
+{ COFF_SECTION_NAME_PARTIAL_MATCH (".gnu.linkonce.wi."), \
+ COFF_ALIGNMENT_FIELD_EMPTY, COFF_ALIGNMENT_FIELD_EMPTY, 0 }
+
#include "coff-arm.c"
[-- Attachment #4: ld-dwarf.diff --]
[-- Type: text/plain, Size: 3791 bytes --]
Index: testsuite/ld-pe/pe.exp
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/pe.exp,v
retrieving revision 1.2
diff -u -p -r1.2 pe.exp
--- testsuite/ld-pe/pe.exp 12 May 2005 07:32:07 -0000 1.2
+++ testsuite/ld-pe/pe.exp 4 Aug 2006 23:25:44 -0000
@@ -17,9 +17,9 @@
# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA.
#
-# This test can only be run on i386 PE/COFF platforms.
+# This test can only be run on PE/COFF platforms that support .secrel32.
if { ![istarget i*86-*-cygwin*] && ![istarget i*86-*-pe]
- && ![istarget i*86-*-mingw*] } {
+ && ![istarget i*86-*-mingw*] && ![istarget arm-wince-pe] } {
return
}
Index: testsuite/ld-pe/secrel.d
===================================================================
RCS file: /cvs/src/src/ld/testsuite/ld-pe/secrel.d,v
retrieving revision 1.2
diff -u -p -r1.2 secrel.d
--- testsuite/ld-pe/secrel.d 29 Sep 2004 13:36:22 -0000 1.2
+++ testsuite/ld-pe/secrel.d 4 Aug 2006 23:25:45 -0000
@@ -1,27 +1,27 @@
-tmpdir/secrel\.x: file format pei-i386
+tmpdir/secrel\.x: +file format pei-.*
Contents of section \.text:
- 401000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 401010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 401020 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 401030 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 401040 ........ ........ ........ ........ ................
+ .*1000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*1010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*1020 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*1030 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*1040 ........ ........ ........ ........ ................
Contents of section \.data:
- 402000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 402010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 402020 3e3e3e3e 04000000 110d0000 00111600 >>>>............
- 402030 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
- 402040 3e3e3e3e 04000000 110d0000 00111600 >>>>............
- 402050 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
- 402060 3e3e3e3e 04000000 110d0000 00111600 >>>>............
- 402070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
- 402080 3e3e3e3e 24000000 112d0000 00113600 >>>>\$....-....6.
- 402090 0000113f 00000011 3c3c3c3c 3c3c3c3c ...\?....<<<<<<<<
+ .*2000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*2010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*2020 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ .*2030 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ .*2040 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ .*2050 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ .*2060 3e3e3e3e 04000000 110d0000 00111600 >>>>............
+ .*2070 0000111f 00000011 3c3c3c3c 3c3c3c3c ........<<<<<<<<
+ .*2080 3e3e3e3e 24000000 112d0000 00113600 >>>>\$....-....6.
+ .*2090 0000113f 00000011 3c3c3c3c 3c3c3c3c ...\?....<<<<<<<<
Contents of section \.rdata:
- 403000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
- 403010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
- 403020 3e3e3e3e 00000000 00000000 00000000 >>>>............
+ .*3000 3e3e3e3e 3c3c3c3c 3e3e3e3e 3e3c3c3c >>>><<<<>>>>><<<
+ .*3010 3e3e3e3e 3e3e3c3c 3e3e3e3e 3e3e3e3c >>>>>><<>>>>>>><
+ .*3020 3e3e3e3e 00000000 00000000 00000000 >>>>............
Contents of section \.idata:
- 404000 00000000 00000000 00000000 00000000 ................
- 404010 00000000 ....
+ .*4000 00000000 00000000 00000000 00000000 ................
+ .*4010 00000000 ....
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-06 14:41 ` Pedro Alves
@ 2006-08-06 14:45 ` Nick Clifton
2006-08-06 14:52 ` Pedro Alves
0 siblings, 1 reply; 10+ messages in thread
From: Nick Clifton @ 2006-08-06 14:45 UTC (permalink / raw)
To: Pedro Alves; +Cc: Andreas Schwab, binutils
Hi Pedro,
> Nick, just to be sure, with "entire patch", you mean bfd+gas+ld, or just
> gas?
bfd+gas+ld
> Also, since I don't have commit privileges, could someone else (Nick?)
> please commit them?
Will do.
Cheers
Nick
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH]: Add DWARF debugging format support for arm-wince-pe
2006-08-06 14:45 ` Nick Clifton
@ 2006-08-06 14:52 ` Pedro Alves
0 siblings, 0 replies; 10+ messages in thread
From: Pedro Alves @ 2006-08-06 14:52 UTC (permalink / raw)
To: Nick Clifton; +Cc: binutils
Nick Clifton wrote:
> Hi Pedro,
>
>> Nick, just to be sure, with "entire patch", you mean bfd+gas+ld, or just
>> gas?
>
> bfd+gas+ld
>
>> Also, since I don't have commit privileges, could someone else (Nick?)
>> please commit them?
>
> Will do.
>
Thanks!
Cheers,
Pedro Alves
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2006-08-06 14:52 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-05 0:39 [PATCH]: Add DWARF debugging format support for arm-wince-pe Pedro Alves
2006-08-05 3:20 ` Daniel Jacobowitz
2006-08-05 12:17 ` Pedro Alves
2006-08-05 18:46 ` Daniel Jacobowitz
2006-08-05 6:57 ` Andreas Schwab
2006-08-05 12:18 ` Pedro Alves
2006-08-06 14:15 ` Nick Clifton
2006-08-06 14:41 ` Pedro Alves
2006-08-06 14:45 ` Nick Clifton
2006-08-06 14:52 ` Pedro Alves
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).