This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils 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]

Re: Disassembly with odd sized section


Hi Subhash,

> Disassembly of section .text:
> 
> 00000000 <.text>:
>    0:   0106            lsl     r6, r0, #4
>    2:   0185            lsl     r5, r0, #6
>    4:   Address 0x4 is out of bounds.
> 
> Disassembly of section .data:
> 
> 00000000 <.data>:
>    0:   0000            lsl     r0, r0, #0
>         ...

> There is a problem in disassembler in handling the trailing byte for
> an odd sized section.  If it is non-zero ( as in text section )it
> gives "Address 0x4 is out of bounds" message.

This is correct.  All Thumb instructions are 2 bytes long.  Therefore
the third instruction would be at bytes 0x4 and 0x5 in the .text
section, but byte 0x5 does not exist.  Hence the instruction at 0x4,
if it existed, would extend into out of bounds memory.

> and if it zero (like in data section) it simply replaces it with
> "...", instead of displaying it as '0x00'.

If you want to see the zeroes, just add the --disassemble-zeroes
command line switch.

>   .text
>      lsl r6, r0, #4       ;some instruction
>      lsl r7, r0, #5       ;some instruction
>      lsl r0, r0, #0

> 00000000 <.text>:
>    0:   0601            lsl     r6, r0, #4
>    2:   4701            lsl     r7, r0, #5
>         ...

> Here instead of disassembling the last instruction in text section
> it is replaced with "...",  because its opcode is "0x0000".
> I think it is a bug in disassembler (objdump.c) for thumb(arm).

Well it is more of a feature, since it can be overcome with
--disassemble-zeroes, and no real piece of code is going to end with
lsl r0,r0,#0 as its last instruction.

Cheers
        Nick


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]