> Date: Fri, 21 Oct 2022 20:02:48 +0000
> From: Klemens Nanni <k...@openbsd.org>
> 
> This is the second biggest read-write global in a sparc64 bsd.mp:
> 0000000001c091b8 g     O .data  0000000000002cb8 sparc_i
> 
> ddb(4) does not ever write to it and happily decodes instructions after
> moving it to .rodata:
> 
>       ddb{3}> x /i %pc
>       db_inst_branch+0x10:    be,pn           db_inst_branch+0x64
>       ddb{3}> x /i db_enter
>       db_enter:       add             %sp, -0xd0, %sp
>       ddb{3}> x /i 0
>       0:      illtrap         0
> 
> Fix two comment typos while here.
> 
> OK?

Be careful.  By moving more stuff into .rodata, you may overflow the
.text/.rodata block.  Make sure you build and test the kernels and
also test an actual bsd.rd.

> diff --git a/sys/arch/sparc64/sparc64/db_disasm.c 
> b/sys/arch/sparc64/sparc64/db_disasm.c
> index b697ad5e163..8924a762dc0 100644
> --- a/sys/arch/sparc64/sparc64/db_disasm.c
> +++ b/sys/arch/sparc64/sparc64/db_disasm.c
> @@ -153,7 +153,7 @@ char *prefetch[] = {
>  /* The sparc instruction table has a format field which tells what
>     the operand structure for this instruction is. Here are the codes:
>  
> -Modifiers (nust be first):
> +Modifiers (must be first):
>       a -- opcode has annul bit
>       p -- opcode has branch prediction bit
>  
> @@ -201,7 +201,7 @@ V8 only:
>  */
>  
>  
> -struct sparc_insn sparc_i[] = {
> +const struct sparc_insn sparc_i[] = {
>  
>       /*
>        * Format 1: Call
> @@ -217,7 +217,7 @@ struct sparc_insn sparc_i[] = {
>       /* Note: if imm22 is zero then this is actually a "nop" grrr... */
>       {(FORMAT2(0, 0x4)), "sethi", "Cd"},
>  
> -     /* Branch on Integer Co`ndition Codes "Bicc" */
> +     /* Branch on Integer Condition Codes "Bicc" */
>       {(FORMAT2(0, 2) | COND(8)), "ba", "a,m"},
>       {(FORMAT2(0, 2) | COND(0)), "bn", "a,m"},
>       {(FORMAT2(0, 2) | COND(9)), "bne", "a,m"},
> @@ -877,7 +877,7 @@ struct sparc_insn sparc_i[] = {
>  vaddr_t
>  db_disasm(vaddr_t loc, int altfmt)
>  {
> -     struct sparc_insn*      i_ptr = (struct sparc_insn *)&sparc_i;
> +     const struct sparc_insn *i_ptr = (const struct sparc_insn *)&sparc_i;
>  
>       unsigned int insn, you_lose, bitmask;
>       int matchp;
> 
> 

Reply via email to