This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
Hi All, GDB is not able to execute "step" command on function calls of Armv8-M cmse secure entry functions. Everytime GNU linker come across definition of any cmse secure entry function in object file(s), it creates two new instructions secure gateway (sg) and original branch destination (b.w), place those two instructions in ".gnu.sgstubs" section of executable. Any function calls to these cmse secure entry functions is re-directed through secure gateway (sg) present in ".gnu.sgstubs" section. Example: Following is a function call to cmse secure entry function "foo": ... bl xxxx <foo> --->(a) ... <foo> xxxx: push {r7, lr} GNU linker on finding out "foo" is a cmse secure entry function, created sg and b.w instructions and place them in ".gnu.sgstubs" section (marked by c). The "bl" instruction (marked by a) which is a call to cmse secure entry function is modified by GNU linker (as marked by b) and call flow is re-directly through secure gateway (sg) in ".gnu.sgstubs" section. ... bl yyyy <foo> ---> (b) ... section .gnu.sgstubs: ---> (c) yyyy <foo> yyyy: sg // secure gateway b.w xxxx <__acle_se_foo> // original_branch_dest ... 0000xxxx <__acle_se_foo> xxxx: push {r7, lr} ---> (d) On invoking GDB, when the control is at "b" and we pass "step" command, the pc returns "yyyy" (sg address) which is a trampoline and which does not exist in source code. So GDB jumps to next line without jumping to "__acle_se_foo" (marked by d). This patch fixes above problem by returning target pc "xxxx" to GDB on executing "step" command at "b", so that the control jumps to "__acle_se_foo" (marked by d). This patch is tested by debugging the CMSE executable using GDB on Aarch32 box. Regression tested for armv7hl-redhat-linux-gnueabi and found no regressions. Ok for master? Hi All, GDB is not able to execute "step" command on function calls of Armv8-M cmse secure entry functions. Everytime GNU linker come across definition of any cmse secure entry function in object file(s), it creates two new instructions secure gateway (sg) and original branch destination (b.w), place those two instructions in ".gnu.sgstubs" section of executable. Any function calls to these cmse secure entry functions is re-directed through secure gateway (sg) present in ".gnu.sgstubs" section. Example: Following is a function call to cmse secure entry function "foo": ... bl xxxx <foo> --->(a) ... <foo> xxxx: push {r7, lr} GNU linker on finding out "foo" is a cmse secure entry function, created sg and b.w instructions and place them in ".gnu.sgstubs" section (marked by c). The "bl" instruction (marked by a) which is a call to cmse secure entry function is modified by GNU linker (as marked by b) and call flow is re-directly through secure gateway (sg) in ".gnu.sgstubs" section. ... bl yyyy <foo> ---> (b) ... section .gnu.sgstubs: ---> (c) yyyy <foo> yyyy: sg // secure gateway b.w xxxx <__acle_se_foo> // original_branch_dest ... 0000xxxx <__acle_se_foo> xxxx: push {r7, lr} ---> (d) On invoking GDB, when the control is at "b" and we pass "step" command, the pc returns "yyyy" (sg address) which is a trampoline and which does not exist in source code. So GDB jumps to next line without jumping to "__acle_se_foo" (marked by d). This patch fixes above problem by returning target pc "xxxx" to GDB on executing "step" command at "b", so that the control jumps to "__acle_se_foo" (marked by d). This patch is tested by debugging the CMSE executable using GDB on Aarch32 box. Regression tested for armv7hl-redhat-linux-gnueabi and found no regressions. Ok for master? gdb/ChangeLog: 2019-07-17 Srinath Parvathaneni <srinath.parvathaneni@arm.com> * arm-tdep.h (check_section_name): New function declaration. * arm-tdep.c (arm_skip_sg_jump_to_bw): New function. When gdb encounters a "step" command on cmse secure entry function (eg:func), this function return an address of "__acle_se_<func>" to PC instead of secure gateaway (sg) address which is present in ".gnu.sgstubs" section. (check_section_name): New function. To check the current section is ".gnu.sgstubs". (arm_skip_stub): Modify to call arm_skip_sg_jump_to_bw function. gdb/testsuite/ChangeLog: 2019-07-17 Srinath Parvathaneni <srinath.parvathaneni@arm.com> * gdb.base/arm-main-cmse.c: New test. * gdb.base/arm-main-cmse.exp: New file.
Attachment:
diff
Description: diff
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |