On Mon, Oct 15, 2012 at 10:41 AM, John Long <codeb...@inbox.lv> wrote:
> On Mon, Oct 15, 2012 at 09:48:57AM -0500, Chris Bennett wrote:
>> On Mon, Oct 15, 2012 at 09:31:34AM -0500, Chris Bennett wrote:
>> > I have added this:
>> >
>> > section .note.openbsd.ident
>> >  align 2
>> >  dd 8
>> >  dd 4
>> >  dd 1
>> >  db 'OpenBSD',0
>> >  dd 0
>> >  align 2
>> >
>> > But get error:
>> >
>> > sfhello.asm:1: error: segment name `.note.openbsd.ident' not recognized
>> >
>>
>> This does work fine if I do this:
>> add note section then compile like this:
>>
>> nasm -f elf32 -o sfhello.o sfhello.asm
>> ld -m elf_i386_obsd -o sfhello sfhello.o
>> ./sfhello
>> Hello, world!
>>
>> Anything wrong with this method?
>
> No, but it is often easier to let gcc invoke the linker.
>
> instead of
>
> ld -m elf_i386_obsd -o sfhello sfhello.o
>
> you could do
>
> gcc -o sfhello sfhello.o
>

that fails to link because _start would be defined in crt, and passing
-nostdlib isn't enough because some pie thing needs atexit. the final
command line with -nopie ends up being more complicated than calling
ld

Reply via email to