linux-assembly.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* ld unresolved symbols
@ 2003-11-06 19:21 Jason Roberts
  2003-11-07 15:26 ` peter w krause
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Roberts @ 2003-11-06 19:21 UTC (permalink / raw)
  To: linux-assembly


Hi all,
I was trying to implement some smc--- someone Maik ? suggested using 
mprotect
to get write acces to code seg. Anyways, nasm will assemble but linker
complains:

smc.o(.text+0x64): In function `protect':
: undefined reference to `_mprotect'

I compiled like this:
nasm -f elf -i/usr/include/sys smc.asm
ld -s smc.o

any help would be appreciated...
I dont want to wade through 85+ pages of dense reading to find the right
'switch' -- I do have a life besides code bashing:)
Thanks
JR




section .data

string     db "normal execution",10,13,0
hstring    db "I am modified!",10,13,0


section .text

global _start
extern _mprotect

_start:

jmp _test

hacked:



mov  edx,17     ;length of buffer
mov  eax,4       ;sys_write
mov  ebx,1       ;file descriptor
mov  ecx,hstring  ;buffer

int  0x80
jmp exit



	_test:

		  call modify
		  xor eax,eax     ;this will be performed but ignored
	hack_me:


                  mov  edx,19     ;length of buffer
                  mov  eax,4       ;sys_write
                  mov  ebx,1       ;file descriptor
                  mov  ecx,string  ;buffer
                  int  0x80

         modify:
	          mov edi, to_write      ;load address of code-to-write in EDI
		  push hack_me           ;save address to write for mprotect
		  call protect
	          mov [hack_me], edi    ;write code to location 'hack_me:'
	          ret                           ;return from call
	to_write:



		  jmp hacked



protect:
             pop edi
             mov ecx,0x2 ;PROT_WRITE
	     push ecx
	     mov ecx,2048
	     push ecx
	     push edi
	     call _mprotect
             ret



exit:

mov ebx,eax
mov eax,1
int 0x80

_________________________________________________________________
Send a QuickGreet with MSN Messenger 
http://www.msnmessenger-download.com/tracking/cdp_games


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

* Re: ld unresolved symbols
@ 2003-11-07  8:02 Maik Beckmann
  0 siblings, 0 replies; 3+ messages in thread
From: Maik Beckmann @ 2003-11-07  8:02 UTC (permalink / raw)
  To: linux-assembly

Hi, sorry i send the first mail only to you but not to this list.

Why do you call mprotect not by int $0x80? 

----- Original Message -----
From: "Jason Roberts" <v3ct0r99@hotmail.com>
Date: 	Thu, 06 Nov 2003 19:21:44 +0000
To: linux-assembly@vger.kernel.org
Subject: ld unresolved symbols

> 
> Hi all,
> I was trying to implement some smc--- someone Maik ? suggested using 
> mprotect
> to get write acces to code seg. Anyways, nasm will assemble but linker
> complains:
> 
> smc.o(.text+0x64): In function `protect':
> : undefined reference to `_mprotect'
> 
> I compiled like this:
> nasm -f elf -i/usr/include/sys smc.asm
> ld -s smc.o
> 
> any help would be appreciated...
> I dont want to wade through 85+ pages of dense reading to find the right
> 'switch' -- I do have a life besides code bashing:)
> Thanks
> JR
> 
> 
> 
> 
> section .data
> 
> string     db "normal execution",10,13,0
> hstring    db "I am modified!",10,13,0
> 
> 
> section .text
> 
> global _start
> extern _mprotect
> 
> _start:
> 
> jmp _test
> 
> hacked:
> 
> 
> 
> mov  edx,17     ;length of buffer
> mov  eax,4       ;sys_write
> mov  ebx,1       ;file descriptor
> mov  ecx,hstring  ;buffer
> 
> int  0x80
> jmp exit
> 
> 
> 
> 	_test:
> 
> 		  call modify
> 		  xor eax,eax     ;this will be performed but ignored
> 	hack_me:
> 
> 
>                   mov  edx,19     ;length of buffer
>                   mov  eax,4       ;sys_write
>                   mov  ebx,1       ;file descriptor
>                   mov  ecx,string  ;buffer
>                   int  0x80
> 
>          modify:
> 	          mov edi, to_write      ;load address of code-to-write in EDI
> 		  push hack_me           ;save address to write for mprotect
> 		  call protect
> 	          mov [hack_me], edi    ;write code to location 'hack_me:'
> 	          ret                           ;return from call
> 	to_write:
> 
> 
> 
> 		  jmp hacked
> 
> 
> 
> protect:
>              pop edi
>              mov ecx,0x2 ;PROT_WRITE
> 	     push ecx
> 	     mov ecx,2048
> 	     push ecx
> 	     push edi
> 	     call _mprotect
>              ret
> 
> 
> 
> exit:
> 
> mov ebx,eax
> mov eax,1
> int 0x80
> 
> _________________________________________________________________
> Send a QuickGreet with MSN Messenger 
> http://www.msnmessenger-download.com/tracking/cdp_games
> 
> -
> To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

-- 
______________________________________________
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

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

* Re: ld unresolved symbols
  2003-11-06 19:21 Jason Roberts
@ 2003-11-07 15:26 ` peter w krause
  0 siblings, 0 replies; 3+ messages in thread
From: peter w krause @ 2003-11-07 15:26 UTC (permalink / raw)
  To: Jason Roberts, linux-assembly

Jason Roberts am Thursday 06 November 2003 19:21:
> Hi all,
> I was trying to implement some smc--- someone Maik ? suggested using
> mprotect
> to get write acces to code seg. Anyways, nasm will assemble but linker
> complains:
>
> smc.o(.text+0x64): In function `protect':
> : undefined reference to `_mprotect'
>
> I compiled like this:
> nasm -f elf -i/usr/include/sys smc.asm
> ld -s smc.o
>
> any help would be appreciated...
> I dont want to wade through 85+ pages of dense reading to find the right
> 'switch' -- I do have a life besides code bashing:)

you expect your readers to do that for you?
where do you assume your label '_mprotect' being?

> Thanks
> JR

-- 
Linux,Assembly,Forth: http://www.lxhp.in-berlin.de/index-lx.shtml
  >> hp -at- lxhp -dot- in-berlin -dot- de <<


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

end of thread, other threads:[~2003-11-07 15:26 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2003-11-07  8:02 ld unresolved symbols Maik Beckmann
  -- strict thread matches above, loose matches on Subject: below --
2003-11-06 19:21 Jason Roberts
2003-11-07 15:26 ` peter w krause

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).