mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* ld bug
@ 2005-06-12 15:10 DJ.CnX
  2005-06-12 16:04 ` Willy Tarreau
  0 siblings, 1 reply; 3+ messages in thread
From: DJ.CnX @ 2005-06-12 15:10 UTC (permalink / raw)
  To: linux-kernel


hello guys....

source:

section .text

global main

msg db "och bin",0x0
msg_len equ $-msg

main:
           pusha
           mov eax,4
           mov ebx,1
           mov ecx,msg
           mov edx,msg_len
           int 0x80

           popa
           xor eax,eax
           inc eax
           int 0x80


compilation command:
sh# nasm -f elf -o new.o new.asm
sh# ld -e main -o new new.o
sh# strace ./new
execve("./new", ["./new"], [/* 78 vars */]) = 0
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++


i compiled the whole shit with gcc and it worked... .-/

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld bug
  2005-06-12 15:10 ld bug DJ.CnX
@ 2005-06-12 16:04 ` Willy Tarreau
  2005-06-12 16:44   ` Jan Engelhardt
  0 siblings, 1 reply; 3+ messages in thread
From: Willy Tarreau @ 2005-06-12 16:04 UTC (permalink / raw)
  To: DJ.CnX; +Cc: linux-kernel

Hello,

On Sun, Jun 12, 2005 at 05:10:50PM +0200, DJ.CnX@phreaker.net wrote:
> 
> hello guys....
> 
> source:
> 
> section .text
> 
> global main
> 
> msg db "och bin",0x0
> msg_len equ $-msg
> 
> main:
>            pusha
>            mov eax,4
>            mov ebx,1
>            mov ecx,msg
>            mov edx,msg_len
>            int 0x80
> 
>            popa
>            xor eax,eax
>            inc eax
>            int 0x80
> 
> 
> compilation command:
> sh# nasm -f elf -o new.o new.asm
> sh# ld -e main -o new new.o
> sh# strace ./new
> execve("./new", ["./new"], [/* 78 vars */]) = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++
> i compiled the whole shit with gcc and it worked... .-/

Although this is not the right list for this, it seems that the start
pointer in your program is 0, and since this page is not mapped, you
get a segfault. How to fix this I don't know, but this definitely is
not a kernel bug.

Willy


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: ld bug
  2005-06-12 16:04 ` Willy Tarreau
@ 2005-06-12 16:44   ` Jan Engelhardt
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Engelhardt @ 2005-06-12 16:44 UTC (permalink / raw)
  To: Willy Tarreau; +Cc: DJ.CnX, linux-kernel

>
>Although this is not the right list for this, it seems that the start
>pointer in your program is 0, and since this page is not mapped, you
>get a segfault. How to fix this I don't know, but this definitely is
>not a kernel bug.

"ld" usually wants a .start symbol (or something...) - and it looks like
nasm does not put some into the object file.

>> compilation command:
>> sh# nasm -f elf -o new.o new.asm
>> sh# ld -e main -o new new.o
>> sh# strace ./new
>> execve("./new", ["./new"], [/* 78 vars */]) = 0
>> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
>> +++ killed by SIGSEGV +++
>> i compiled the whole shit with gcc and it worked... .-/

Well, I did the same with GCC (GNU AS):

.intel_syntax noprefix;
.section .rodata;
.L_LC0:
	.string "och bin";
.text;
	pusha;
	mov eax, 4;
	mov ebx, 1;
	mov ecx, offset flat:.L_LC0;
	mov edx, 8;
	int 0x80;

18:43 eax:../hxtools/examples # cc x.S -c
18:43 eax:../hxtools/examples # ld x.o -o x.aout
ld: warning: cannot find entry symbol _start; defaulting to 0000000008048074
18:43 eax:../hxtools/examples # ./x.aout 
och binSegmentation fault

- The segfault is due to the abrupt end after int 0x80,
  so let's not consider it.

- "och bin" is printed

- As you can see, there is said _start symbol which I presume NASM
  fails to generate.



Jan Engelhardt                                                               
--                                                                            
| Gesellschaft fuer Wissenschaftliche Datenverarbeitung Goettingen,
| Am Fassberg, 37077 Goettingen, www.gwdg.de

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2005-06-12 19:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-06-12 15:10 ld bug DJ.CnX
2005-06-12 16:04 ` Willy Tarreau
2005-06-12 16:44   ` Jan Engelhardt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®