This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Fix build break on ARM
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: gdb-patches at sourceware dot org
- Cc: yao at codesourcery dot com
- Date: Wed, 2 Feb 2011 19:08:16 +0100 (CET)
- Subject: [commit] Fix build break on ARM
Hello,
I'm getting build failures due to:
gdb/arm-tdep.c: In function 'arm_skip_prologue':
gdb/arm-tdep.c:1163:21: error: 'high' may be used uninitialized in this function
which appears to be correct; if arm_analyze_load_stack_chk_guard (in the
ARM case) finds just a movw which is not followed by a movt, it will access
an uninitialized value from the "high" variable.
In the Thumb case, the function checks that it finds *both* movw and movt.
The same should be done for the ARM case. The patch below makes this
change (and fixes the incorrect indentation of that case at the same
time).
Tested on armv7l-linux-gnueabi.
Committed to mainline.
Bye,
Ulrich
ChangeLog:
* arm-tdep.c (arm_analyze_load_stack_chk_guard): Avoid build break
due to accessing uninitialized variable. Fix indentation.
Index: gdb/arm-tdep.c
===================================================================
RCS file: /cvs/src/src/gdb/arm-tdep.c,v
retrieving revision 1.321
diff -u -p -r1.321 arm-tdep.c
--- gdb/arm-tdep.c 14 Jan 2011 20:37:13 -0000 1.321
+++ gdb/arm-tdep.c 2 Feb 2011 16:21:35 -0000
@@ -1198,29 +1198,30 @@ arm_analyze_load_stack_chk_guard(CORE_AD
}
else
{
- unsigned int insn
- = read_memory_unsigned_integer (pc, 4, byte_order_for_code);
-
- if ((insn & 0x0e5f0000) == 0x041f0000) /* ldr Rd, #immed */
- {
- address = bits (insn, 0, 11);
- *destreg = bits (insn, 12, 15);
- *offset = 4;
- }
- else if ((insn & 0x0ff00000) == 0x03000000) /* movw Rd, #const */
- {
- low = EXTRACT_MOVW_MOVT_IMM_A (insn);
+ unsigned int insn
+ = read_memory_unsigned_integer (pc, 4, byte_order_for_code);
- insn
- = read_memory_unsigned_integer (pc + 4, 4, byte_order_for_code);
+ if ((insn & 0x0e5f0000) == 0x041f0000) /* ldr Rd, #immed */
+ {
+ address = bits (insn, 0, 11);
+ *destreg = bits (insn, 12, 15);
+ *offset = 4;
+ }
+ else if ((insn & 0x0ff00000) == 0x03000000) /* movw Rd, #const */
+ {
+ low = EXTRACT_MOVW_MOVT_IMM_A (insn);
- if ((insn & 0x0ff00000) == 0x03400000) /* movt Rd, #const */
- high = EXTRACT_MOVW_MOVT_IMM_A (insn);
+ insn
+ = read_memory_unsigned_integer (pc + 4, 4, byte_order_for_code);
- address = (high << 16 | low);
- *destreg = bits (insn, 12, 15);
- *offset = 8;
- }
+ if ((insn & 0x0ff00000) == 0x03400000) /* movt Rd, #const */
+ {
+ high = EXTRACT_MOVW_MOVT_IMM_A (insn);
+ *destreg = bits (insn, 12, 15);
+ *offset = 8;
+ address = (high << 16 | low);
+ }
+ }
}
return address;
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com