Port-amd64 archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: x86 assembly question
On Mon, Sep 08, 2025 at 10:38:13PM +0200, Manuel Bouyer wrote:
> Hello,
> I suspect that some assembly code is not doing what I think it should.
> But as it's in the early stage of boot it's hard to debug.
>
> Here's the (32bits) code:
> push %ebx /* save start_info to stack */
> /* do stuff */
> movl $RELOC(__kernel_end), %ebp
> addl $3, %ebp
> andl $~3, %ebp
> movl 0(%ebp), %eax /* read size */
> addl %ebp, %eax /* compute esym */
> /* check if start_info is within symbol table */
> movl -4(%esp), %ebx
> cmp %ebx, %ebp;
> jb .save_esym /* %ebx < __kernel_end */
> cmp %ebx, %eax
> jae .save_esym /* %ebx >= esym */
> /* no symbol table */
I had 2 issues there:
- the last pushed value is 0(%esp), not -4 because the stack grows down
(thanks Joachim Kuebart for pointing this out)
- I got confused by cmp's argument order being the opposite between
intel and gas syntax. As a result the "no symbol table" code was
unreacheable.
--
Manuel Bouyer <bouyer%antioche.eu.org@localhost>
NetBSD: 26 ans d'experience feront toujours la difference
--
Home |
Main Index |
Thread Index |
Old Index