Is 4 byte -1 invalid code on most/all architectures?

David Daney ddaney@caviumnetworks.com
Thu Dec 9 01:12:00 GMT 2010


On 12/08/2010 05:08 PM, Jay K wrote:
>
>> I'm a student around here, but I think the way you're doing this is
>> daft. Do it properly.
>
>
>
> I don't believe there is a proper way.
> As I said, it's not my invention, I was aghast at first to find it,
> (having brought up one of the targets where alignment matters
> and debugging the alignment fault)
> but upon much further thought, I believe there is no good solution.
> I'd very much appreciate hearing otherwise.
> Generating code at runtime on the stack I don't consider a good solution.
>    Maybe for certain targets though, if we can guarantee
>    that the stack is executable. That's probably fairly rare these days though.
>

Most Linux kernel based systems will give you an executable stack if you 
ask for it by setting the GNU executable stack attribute on your executable.

David Daney


>
>> If the x86 processor is in 32-bit or 64-bit mode, -1 resolves to:
>
>
> Is my x86 and amd64 debugger wrong?
>
>
> 772809bd ff              ???
> 772809be ff              ???
> 772809bf ff              ???
> 772809c0 ff              ???
> 772809c1 ff              ???
>
>
>
>   >   ISA manuals for all the processors you are interested in are available to you.
>
>
> It's bit much to wade through.
> The IA64 manual at least is confusing. Various fields, color coding,
>   I'm not sure which bits are being referred to...
> I'll try to read others. I imagine they are all much easier.
>
>
>
>   >  No. On MIPS I think 0xffffffff ->  SD $31,-1($31)
>
>
> Ugh, that seems unfortunate for us.
> There is an additional saving grace that these are pointers to the starts of functions,
> and necessarily written in a high level language and compiled by gcc, but I understand
> that that isn't necessarily particularly restrictive.
>
>
>
> Thanks,
>   - Jay
>
>
> ----------------------------------------
>> To: jay.krell@cornell.edu; gcc-help@gcc.gnu.org
>> Subject: Re: Is 4 byte -1 invalid code on most/all architectures?
>> Date: Wed, 8 Dec 2010 19:59:40 -0500
>> From: richardcavell@mail.com
>>
>> If the x86 processor is in 16-bit mode, -1 resolves to:
>>
>> pop sp
>> js 0x69
>>
>> If the x86 processor is in 32-bit or 64-bit mode, -1 resolves to:
>>
>> pop esp
>> js 0x69
>>
>> I'm a student around here, but I think the way you're doing this is
>> daft. Do it properly.
>>
>> Richard 		 	   		
>



More information about the Gcc-help mailing list