summaryrefslogtreecommitdiffstats
path: root/meta/packages/gcc/gcc-3.3.4/arm-gotoff.dpatch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/gcc/gcc-3.3.4/arm-gotoff.dpatch')
-rw-r--r--meta/packages/gcc/gcc-3.3.4/arm-gotoff.dpatch135
1 files changed, 135 insertions, 0 deletions
diff --git a/meta/packages/gcc/gcc-3.3.4/arm-gotoff.dpatch b/meta/packages/gcc/gcc-3.3.4/arm-gotoff.dpatch
new file mode 100644
index 0000000000..610f9430e0
--- /dev/null
+++ b/meta/packages/gcc/gcc-3.3.4/arm-gotoff.dpatch
@@ -0,0 +1,135 @@
1#! /bin/sh -e
2
3src=gcc
4if [ $# -eq 3 -a "$2" = '-d' ]; then
5 pdir="-d $3"
6 src=$3/gcc
7elif [ $# -ne 1 ]; then
8 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
9 exit 1
10fi
11case "$1" in
12 -patch)
13 patch $pdir -f --no-backup-if-mismatch -p0 --fuzz 10 < $0
14 ;;
15 -unpatch)
16 patch $pdir -f --no-backup-if-mismatch -R -p0 --fuzz 10 < $0
17 ;;
18 *)
19 echo >&2 "`basename $0`: script expects -patch|-unpatch as argument"
20 exit 1
21esac
22exit 0
23
24# DP: use GOTOFF not GOT relocs for .LCn and other local symbols;
25# DP: don't use gotoff for non-static functions, even if defined locally
26
27--- gcc/config/arm/arm.c 2003-06-14 15:20:53.000000000 +0100
28+++ gcc/config/arm/arm.c 2004-03-06 15:15:32.000000000 +0000
29@@ -2364,6 +2394,40 @@
30 return 1;
31 }
32
33+/* Return true if OP is a symbolic operand that resolves locally. */
34+
35+static int
36+local_symbolic_operand (op, mode)
37+ rtx op;
38+ enum machine_mode mode ATTRIBUTE_UNUSED;
39+{
40+ if (GET_CODE (op) == CONST
41+ && GET_CODE (XEXP (op, 0)) == PLUS
42+ && GET_CODE (XEXP (XEXP (op, 0), 1)) == CONST_INT)
43+ op = XEXP (XEXP (op, 0), 0);
44+
45+ if (GET_CODE (op) == LABEL_REF)
46+ return 1;
47+
48+ if (GET_CODE (op) != SYMBOL_REF)
49+ return 0;
50+
51+ /* These we've been told are local by varasm and encode_section_info
52+ respectively. */
53+ if (CONSTANT_POOL_ADDRESS_P (op) || ENCODED_LOCAL_BINDING_ATTR_P (XSTR (op, 0)))
54+ return 1;
55+
56+ /* There is, however, a not insubstantial body of code in the rest of
57+ the compiler that assumes it can just stick the results of
58+ ASM_GENERATE_INTERNAL_LABEL in a symbol_ref and have done. */
59+ /* ??? This is a hack. Should update the body of the compiler to
60+ always create a DECL an invoke targetm.encode_section_info. */
61+ if (strncmp (arm_strip_name_encoding (XSTR (op, 0)), ".L", 2) == 0)
62+ return 1;
63+
64+ return 0;
65+}
66+
67 rtx
68 legitimize_pic_address (orig, mode, reg)
69 rtx orig;
70@@ -2404,10 +2468,7 @@
71 else
72 emit_insn (gen_pic_load_addr_thumb (address, orig));
73
74- if ((GET_CODE (orig) == LABEL_REF
75- || (GET_CODE (orig) == SYMBOL_REF &&
76- ENCODED_SHORT_CALL_ATTR_P (XSTR (orig, 0))))
77- && NEED_GOT_RELOC)
78+ if (local_symbolic_operand (orig, Pmode) && NEED_GOT_RELOC)
79 pic_ref = gen_rtx_PLUS (Pmode, pic_offset_table_rtx, address);
80 else
81 {
82@@ -8804,11 +8911,7 @@
83 if (NEED_GOT_RELOC && flag_pic && making_const_table &&
84 (GET_CODE (x) == SYMBOL_REF || GET_CODE (x) == LABEL_REF))
85 {
86- if (GET_CODE (x) == SYMBOL_REF
87- && (CONSTANT_POOL_ADDRESS_P (x)
88- || ENCODED_SHORT_CALL_ATTR_P (XSTR (x, 0))))
89- fputs ("(GOTOFF)", asm_out_file);
90- else if (GET_CODE (x) == LABEL_REF)
91+ if (local_symbolic_operand (x, Pmode))
92 fputs ("(GOTOFF)", asm_out_file);
93 else
94 fputs ("(GOT)", asm_out_file);
95@@ -11335,6 +11418,11 @@
96 else if (! TREE_PUBLIC (decl))
97 arm_encode_call_attribute (decl, SHORT_CALL_FLAG_CHAR);
98 }
99+
100+ if (TREE_CODE_CLASS (TREE_CODE (decl)) == 'd'
101+ && flag_pic
102+ && (*targetm.binds_local_p) (decl))
103+ arm_encode_call_attribute (decl, LOCAL_BINDING_FLAG_CHAR);
104 }
105 #endif /* !ARM_PE */
106
107
108--- gcc/config/arm/arm.h Fri Mar 5 18:49:44 2004
109+++ gcc/config/arm/arm.h Fri Mar 5 15:04:31 2004
110@@ -1870,6 +1870,7 @@
111 Note, '@' and '*' have already been taken. */
112 #define SHORT_CALL_FLAG_CHAR '^'
113 #define LONG_CALL_FLAG_CHAR '#'
114+#define LOCAL_BINDING_FLAG_CHAR '%'
115
116 #define ENCODED_SHORT_CALL_ATTR_P(SYMBOL_NAME) \
117 (*(SYMBOL_NAME) == SHORT_CALL_FLAG_CHAR)
118@@ -1877,6 +1878,9 @@
119 #define ENCODED_LONG_CALL_ATTR_P(SYMBOL_NAME) \
120 (*(SYMBOL_NAME) == LONG_CALL_FLAG_CHAR)
121
122+#define ENCODED_LOCAL_BINDING_ATTR_P(SYMBOL_NAME) \
123+ (*(SYMBOL_NAME) == LOCAL_BINDING_FLAG_CHAR)
124+
125 #ifndef SUBTARGET_NAME_ENCODING_LENGTHS
126 #define SUBTARGET_NAME_ENCODING_LENGTHS
127 #endif
128@@ -1888,6 +1892,7 @@
129 #define ARM_NAME_ENCODING_LENGTHS \
130 case SHORT_CALL_FLAG_CHAR: return 1; \
131 case LONG_CALL_FLAG_CHAR: return 1; \
132+ case LOCAL_BINDING_FLAG_CHAR: return 1; \
133 case '*': return 1; \
134 SUBTARGET_NAME_ENCODING_LENGTHS
135