Skip to content

Commit 7e3aa8d

Browse files
committed
patch applied to the original sourcery binutils
1 parent 91119f6 commit 7e3aa8d

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

gnutools-2014.patch

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
diff -duwr xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/bfd/hexagon-isa.c hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/bfd/hexagon-isa.c
2+
--- xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/bfd/hexagon-isa.c 2015-09-22 18:42:23.000000000 +0200
3+
+++ hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/bfd/hexagon-isa.c 2017-03-08 20:16:07.000000000 +0100
4+
@@ -1371,6 +1371,72 @@
5+
|| hexagon_if_arch_v55 ();
6+
}
7+
8+
+//// >>>> itsme
9+
+static int is_valid_ptr(const void *p)
10+
+{
11+
+ // pass it to a syscall - https://stackoverflow.com/questions/551069/testing-pointers-for-validity-c-c
12+
+ access(p, 0);
13+
+ return errno!=EFAULT;
14+
+}
15+
+static int is_valid_ptr_or_null(const void *p)
16+
+{
17+
+ return p==NULL || is_valid_ptr(p);
18+
+}
19+
+static int is_valid_opcode(const hexagon_opcode *p)
20+
+{
21+
+ return is_valid_ptr(p->syntax)
22+
+ && is_valid_ptr(p->enc)
23+
+ && is_valid_ptr_or_null(p->next_asm)
24+
+ && is_valid_ptr_or_null(p->next_dis)
25+
+ && (p->slots < 16)
26+
+ && (p->implicit < 0x1000)
27+
+ && (p->attributes < 0x02000000)
28+
+ && is_valid_ptr_or_null(p->map);
29+
+}
30+
+static int check_icode_map(int all)
31+
+{
32+
+ FILE *flog;
33+
+ if (all) {
34+
+ flog = fopen("icodecheck.log", "a+");
35+
+ }
36+
+ for (int icode = 0 ; icode< (1 << hexagon_icode_hash_bits) ; icode++)
37+
+ {
38+
+ const hexagon_opcode *prev = NULL;
39+
+ for (const hexagon_opcode *opcode = icode_map[icode] ; opcode ; prev = opcode, opcode = opcode->next_dis)
40+
+ {
41+
+ if ( !is_valid_ptr(opcode) ) {
42+
+ if (!all) { flog = fopen("icodecheck.log", "a+"); }
43+
+ fprintf(flog, "icode = %08x: %p -> next_dis = %p - invalid ptr\n", icode, prev, opcode);
44+
+ if (!all) { fclose(flog); return FALSE; }
45+
+ }
46+
+ else if (!is_valid_opcode(opcode)) {
47+
+ if (!all) { flog = fopen("icodecheck.log", "a+"); }
48+
+ fprintf(flog, "icode = %08x: %p -> next_dis = %p - invalid item\n", icode, prev, opcode);
49+
+ if (!all) { fclose(flog); return FALSE; }
50+
+ }
51+
+ }
52+
+ for (const hexagon_opcode *opcode = icode_map[icode] ; opcode ; prev = opcode, opcode = opcode->next_asm)
53+
+ {
54+
+ if ( !is_valid_ptr(opcode) ) {
55+
+ if (!all) { flog = fopen("icodecheck.log", "a+"); }
56+
+ fprintf(flog, "icode = %08x: %p -> next_asm = %p - invalid ptr\n", icode, prev, opcode);
57+
+ if (!all) { fclose(flog); return FALSE; }
58+
+ }
59+
+ else if (!is_valid_opcode(opcode)) {
60+
+ if (!all) { flog = fopen("icodecheck.log", "a+"); }
61+
+ fprintf(flog, "icode = %08x: %p -> next_asm = %p - invalid item\n", icode, prev, opcode);
62+
+ if (!all) { fclose(flog); return FALSE; }
63+
+ }
64+
+ }
65+
+ }
66+
+ if (all) {
67+
+ fprintf(flog, "icode map OK\n");
68+
+ fclose(flog);
69+
+ }
70+
+ return TRUE;
71+
+}
72+
+//// <<<< itsme
73+
+
74+
75+
/* Install OPCODE in the lookup tables. */
76+
static void
77+
@@ -1452,6 +1518,7 @@
78+
if (hexagon_if_arch_kext ())
79+
assert (hexagon_kext_opcode);
80+
81+
+ //check_icode_map(TRUE);
82+
#if 0
83+
puts ("Hash Table Depth:");
84+
for (i = 0; i < HEXAGON_HASH_SIZE; i++)
85+
@@ -1721,9 +1788,12 @@
86+
/* Reset the packet bits. */
87+
insn = HEXAGON_END_PACKET_RESET (insn);
88+
89+
+
90+
for (opcode = hexagon_opcode_lookup_dis (insn);
91+
opcode; opcode = HEXAGON_CODE_NEXT_DIS (opcode))
92+
{
93+
+ if (!is_valid_ptr(opcode) || !is_valid_opcode(opcode))
94+
+ check_icode_map(FALSE);
95+
if (opcode->map)
96+
continue;
97+
98+
diff -duwr xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/binutils/readelf.c hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/binutils/readelf.c
99+
--- xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/binutils/readelf.c 2015-09-22 18:42:19.000000000 +0200
100+
+++ hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/binutils/readelf.c 2018-02-14 15:02:45.000000000 +0100
101+
@@ -8963,7 +8963,7 @@
102+
103+
n = print_vma (si, DEC_5);
104+
if (n < 5)
105+
- fputs (" " + n, stdout);
106+
+ fputs (&" "[n], stdout);
107+
printf (" %3lu: ", hn);
108+
print_vma (psym->st_value, LONG_HEX);
109+
putchar (' ');
110+
diff -duwr xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/include/hexagon-isa.h hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/include/hexagon-isa.h
111+
--- xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/include/hexagon-isa.h 2015-09-22 18:42:17.000000000 +0200
112+
+++ hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/include/hexagon-isa.h 2018-02-14 14:54:38.000000000 +0100
113+
@@ -28,16 +28,16 @@
114+
#define MAX_PACKET_INSNS 4
115+
116+
/* Extract the low 16 bits. */
117+
-#define HEXAGON_LO16(num) ((num) & ~(-1 << 16))
118+
+#define HEXAGON_LO16(num) ((num) & ~((-1u) << 16))
119+
120+
/* Extract the high 16 bits. */
121+
#define HEXAGON_HI16(num) HEXAGON_LO16 ((num) >> 16)
122+
123+
/* Extract the extender bits. */
124+
-#define HEXAGON_KXER_MASK(num) ((num) & (~0L << 6))
125+
+#define HEXAGON_KXER_MASK(num) ((num) & ((~0UL) << 6))
126+
127+
/* Extract the extended bits. */
128+
-#define HEXAGON_KXED_MASK(num) ((num) & ~(~0L << 6))
129+
+#define HEXAGON_KXED_MASK(num) ((num) & ~((~0UL) << 6))
130+
131+
/* Specify the register sub-ranges. */
132+
#define HEXAGON_SUBREGS 16
133+
diff -duwr xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/opcodes/hexagon-dis.c hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/opcodes/hexagon-dis.c
134+
--- xhx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/opcodes/hexagon-dis.c 2015-09-22 18:42:25.000000000 +0200
135+
+++ hx/sourceryg++-2012.03-151-hexagon/binutils-hexagon-2012.03/opcodes/hexagon-dis.c 2016-01-29 18:03:55.000000000 +0100
136+
@@ -91,8 +91,8 @@
137+
/* Disassemble. */
138+
hexagon_dis_inst (address, insn, buffer, info);
139+
140+
- /* Display the disassembly instruction. */
141+
- (*func) (stream, "%08x ", insn);
142+
+// /* Display the disassembly instruction. */
143+
+// (*func) (stream, "%08x ", insn);
144+
145+
/* Print the instruction buffer.
146+
Watch out for placeholders where we want

0 commit comments

Comments
 (0)