This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
[PATCH] Allow targets to override diff expression generation in w2gencfi.c
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: binutils at sourceware dot org
- Cc: rth at twiddle dot net, sje at cup dot hp dot com
- Date: Sat, 30 Aug 2008 14:10:22 -0400 (EDT)
- Subject: [PATCH] Allow targets to override diff expression generation in w2gencfi.c
On the hppa64-hp-hpux11*, difference expressions can't be used during
CFI generation since differences between text and data symbols don't
work in shared objects. The dynamic loader independently relocates
the text and data segments of shared objects and doesn't maintain a
fixed relationship between the text and data segments.
When DIFF_EXPR_OK is defined, the code in dw2gencfi.c automatically
assumes that it can use difference expressions during CFI generation.
It would be possible to not define DIFF_EXPR_OK on this target, but
I believe there are still circumstances were difference expressions
are useful. In particular, it improves compatibility with the HP
assembler. So, I revised dw2gencfi.c to provide a mechanism to
override its use of DIFF_EXPR_OK.
Tested on hppa64-hp-hpux11.11.
Ok?
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2008-08-30 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
* dw2gencfi.c (CFI_DIFF_EXPR_OK): Define if not defined.
(dot_cfi_personality): Use CFI_DIFF_EXPR_OK instead of DIFF_EXPR_OK.
(dot_cfi_lsda, output_cie, output_fde): Likewise.
* config/tc-hppa.h (CFI_DIFF_EXPR_OK): Define.
Index: dw2gencfi.c
===================================================================
RCS file: /cvs/src/src/gas/dw2gencfi.c,v
retrieving revision 1.35
diff -u -3 -p -r1.35 dw2gencfi.c
--- dw2gencfi.c 21 Aug 2008 19:49:22 -0000 1.35
+++ dw2gencfi.c 30 Aug 2008 17:43:01 -0000
@@ -25,6 +25,15 @@
#ifdef TARGET_USE_CFIPOP
+/* By default, use difference expressions if DIFF_EXPR_OK is defined. */
+#ifndef CFI_DIFF_EXPR_OK
+# ifdef DIFF_EXPR_OK
+# define CFI_DIFF_EXPR_OK 1
+# else
+# define CFI_DIFF_EXPR_OK 0
+# endif
+#endif
+
/* We re-use DWARF2_LINE_MIN_INSN_LENGTH for the code alignment field
of the CIE. Default to 1 if not otherwise specified. */
#ifndef DWARF2_LINE_MIN_INSN_LENGTH
@@ -655,7 +664,7 @@ dot_cfi_personality (int ignored ATTRIBU
if ((encoding & 0xff) != encoding
|| ((encoding & 0x70) != 0
-#if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
+#if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
&& (encoding & 0x70) != DW_EH_PE_pcrel
#endif
)
@@ -725,7 +734,7 @@ dot_cfi_lsda (int ignored ATTRIBUTE_UNUS
if ((encoding & 0xff) != encoding
|| ((encoding & 0x70) != 0
-#if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
+#if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
&& (encoding & 0x70) != DW_EH_PE_pcrel
#endif
)
@@ -1092,7 +1101,7 @@ output_cie (struct cie_entry *cie)
exp = cie->personality;
if ((cie->per_encoding & 0x70) == DW_EH_PE_pcrel)
{
-#ifdef DIFF_EXPR_OK
+#if CFI_DIFF_EXPR_OK
exp.X_op = O_subtract;
exp.X_op_symbol = symbol_temp_new_now ();
emit_expr (&exp, size);
@@ -1122,7 +1131,7 @@ output_cie (struct cie_entry *cie)
default:
abort ();
}
-#if defined DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
+#if CFI_DIFF_EXPR_OK || defined tc_cfi_emit_pcrel_expr
enc |= DW_EH_PE_pcrel;
#endif
out_one (enc);
@@ -1157,7 +1166,7 @@ output_fde (struct fde_entry *fde, struc
exp.X_op_symbol = cie->start_address;
emit_expr (&exp, 4); /* CIE offset. */
-#ifdef DIFF_EXPR_OK
+#ifdef CFI_DIFF_EXPR_OK
exp.X_add_symbol = fde->start_address;
exp.X_op_symbol = symbol_temp_new_now ();
emit_expr (&exp, DWARF2_FDE_RELOC_SIZE); /* Code offset. */
@@ -1185,7 +1194,7 @@ output_fde (struct fde_entry *fde, struc
exp = fde->lsda;
if ((fde->lsda_encoding & 0x70) == DW_EH_PE_pcrel)
{
-#ifdef DIFF_EXPR_OK
+#ifdef CFI_DIFF_EXPR_OK
exp.X_op = O_subtract;
exp.X_op_symbol = symbol_temp_new_now ();
emit_expr (&exp, augmentation_size);
Index: config/tc-hppa.h
===================================================================
RCS file: /cvs/src/src/gas/config/tc-hppa.h,v
retrieving revision 1.38
diff -u -3 -p -r1.38 tc-hppa.h
--- config/tc-hppa.h 30 Aug 2008 15:52:22 -0000 1.38
+++ config/tc-hppa.h 30 Aug 2008 17:43:01 -0000
@@ -222,6 +232,10 @@ extern int hppa_regname_to_dw2regnum (ch
/* Due to the way dynamic linking to personality functions is handled
on HP-UX, we need to have a read-write .eh_frame section. */
#define DWARF2_EH_FRAME_READ_ONLY 0
+
+/* Because differences between text and data symbols don't work, we
+ can't use difference expressions during CFI generation. */
+#define CFI_DIFF_EXPR_OK 0
#endif
#endif /* OBJ_ELF */