Re: indexing arrays

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/18/2013 03:47 AM, Mischa Baars wrote:
> On 11/17/2013 11:05 PM, Florian Weimer wrote:
>> * Mischa Baars:
>>
>>> Please have a look at the following example, and let me know what
>>> you think.
>> The code doesn't contain any comments, so we don't know what you're
>> trying to do.
> 
> The assembly file does, if you would just look at it.
> 
> As you can see, the 'ebx' register is unprotected when the function is 
> called from a location other than 'main'. Normally I shouldn't be able 
> to modify the array index from the assembly.

You're doing it wrong.  It is the job of the called function to save and
restore %ebx:

%ebx     As described below, this register serves as the global offset
         table base register for position-independent code. For
         absolute code, %ebx serves as a local register and has no
         specified role in the function calling sequence. In either
         case, a function must preserve the register value for the
         caller.

Andrew.


http://www.sco.com/developers/devspecs/abi386-4.pdf




[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux