arm-elf-gcc 는 크게 두가지 놈이 있는데,
그놈에서 만든 거랑 야가토에서 만든게,
야가토가 좀더 쉬워서 야가토로 하겠다
http://www.yagarto.de/
여기 들어가서
맥용 다운 받고
설치한다...;;
그냥 거의 압축 푸는 수준이다....;;;
필자는
/usr/local/yagarto에 설치했다..(그냥 압축 푼다와 동일하다)
그렇게 하고
패스 설정 하고....
.bash_profile 여기다가 패스 설정하면 된다.
위치는 아마 루트에 있을것이다.
패스 설정하는 법은 그냥 쓰면 된다
export PATH=/usr/local/yagarto:$PATH
그 파일이 없다면
그냥 admin 권한 있는 사용자 루트폴더에
.profile에다가 써넣어라
암튼 그렇게 하고
arm-elf-gcc --version 등의 명령어를 쳐서
arm-elf-gcc (GCC) 4.4.1
Copyright (C) 2009 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
이런 비스무리한게 나오면 성공한거다..
여기서 힘난 당신 분명 컴파일을 해보고 싶을 꺼다
그래서 다음 과 같은 소스를 코딩한다음 됬는지를 확인하겠지
#include <stdio.h>
int main(){
printf("Hello World!\n");
return 0;
}
그렇게 하고
arm-elf-gcc -o hello.o hello.c
뭐 이렇게 쓰면
엄청난 안될것이다..
되면 다행이고
아마 다음과 같은 에러가 뜰텐데
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-exit.o): In function `exit':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdlib/../../../../../newlib-1.17.0/newlib/libc/stdlib/exit.c:65: undefined reference to `_exit'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-mallocr.o): In function `malloc_extend_top':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdlib/../../../../../newlib-1.17.0/newlib/libc/stdlib/mallocr.c:2160: undefined reference to `_sbrk_r'
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdlib/../../../../../newlib-1.17.0/newlib/libc/stdlib/mallocr.c:2197: undefined reference to `_sbrk_r'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-freer.o): In function `_malloc_trim_r':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdlib/../../../../../newlib-1.17.0/newlib/libc/stdlib/mallocr.c:3326: undefined reference to `_sbrk_r'
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdlib/../../../../../newlib-1.17.0/newlib/libc/stdlib/mallocr.c:3335: undefined reference to `_sbrk_r'
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdlib/../../../../../newlib-1.17.0/newlib/libc/stdlib/mallocr.c:3340: undefined reference to `_sbrk_r'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-makebuf.o): In function `__smakebuf_r':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/makebuf.c:59: undefined reference to `_fstat_r'
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/makebuf.c:110: undefined reference to `_isatty_r'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-stdio.o): In function `__sclose':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/stdio.c:124: undefined reference to `_close_r'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-stdio.o): In function `__sseek':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/stdio.c:106: undefined reference to `_lseek_r'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-stdio.o): In function `__swrite':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/stdio.c:78: undefined reference to `_lseek_r'
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/stdio.c:86: undefined reference to `_write_r'
/usr/local/yagarto-4.4.1/bin/../lib/gcc/arm-elf/4.4.1/../../../../arm-elf/lib/libc.a(lib_a-stdio.o): In function `__sread':
/Users/mfischer/Projekte/development/yagarto-build/newlib-build/arm-elf/newlib/libc/stdio/../../../../../newlib-1.17.0/newlib/libc/stdio/stdio.c:48: undefined reference to `_read_r'
collect2: ld returned 1 exit status
긴장하지마라.
당신은 잘못설치한게 아니다..
단지 저런 파일에 대한 링크 에러가 난것이다.
뭐 이런저런 과정을 격을 텐데....
Red Hat newlib C Library" documentation 이문서 공부하고 어쩌구 말이다
그런 과정은 싹 빼고 되는법을 알려주마
/****************************************************************************
* Copyright (c) 2009 by Michael Fischer. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the author nor the names of its contributors may
* be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
* THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
* THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
****************************************************************************
* History:
*
* 28.03.09 mifi First Version, based on the original syscall.c from
* newlib version 1.17.0
****************************************************************************/
#include <stdlib.h>
#include <errno.h>
#include <string.h>
#include <sys/stat.h>
#include <sys/types.h>
/***************************************************************************/
int _read_r (struct _reent *r, int file, char * ptr, int len)
{
r = r;
file = file;
ptr = ptr;
len = len;
errno = EINVAL;
return -1;
}
/***************************************************************************/
int _lseek_r (struct _reent *r, int file, int ptr, int dir)
{
r = r;
file = file;
ptr = ptr;
dir = dir;
return 0;
}
/***************************************************************************/
int _write_r (struct _reent *r, int file, char * ptr, int len)
{
r = r;
file = file;
ptr = ptr;
#if 0
int index;
/* For example, output string by UART */
for(index=0; index<len; index++)
{
if (ptr[index] == '\n')
{
uart_putc('\r');
}
uart_putc(ptr[index]);
}
#endif
return len;
}
/***************************************************************************/
int _close_r (struct _reent *r, int file)
{
return 0;
}
/***************************************************************************/
/* Register name faking - works in collusion with the linker. */
register char * stack_ptr asm ("sp");
caddr_t _sbrk_r (struct _reent *r, int incr)
{
extern char end asm ("end"); /* Defined by the linker. */
static char * heap_end;
char * prev_heap_end;
if (heap_end == NULL)
heap_end = & end;
prev_heap_end = heap_end;
if (heap_end + incr > stack_ptr)
{
/* Some of the libstdc++-v3 tests rely upon detecting
out of memory errors, so do not abort here. */
#if 0
extern void abort (void);
_write (1, "_sbrk: Heap and stack collision\n", 32);
abort ();
#else
errno = ENOMEM;
return (caddr_t) -1;
#endif
}
heap_end += incr;
return (caddr_t) prev_heap_end;
}
/***************************************************************************/
int _fstat_r (struct _reent *r, int file, struct stat * st)
{
r = r;
file = file;
memset (st, 0, sizeof (* st));
st->st_mode = S_IFCHR;
return 0;
}
/***************************************************************************/
int _isatty_r(struct _reent *r, int fd)
{
r = r;
fd = fd;
return 1;
}
/****************************************************************************/
void _exit(int n)
{
while(1);
}
/*** EOF ***/
여기까지 소스를 싹 복사해다가
라이브러리를 만들면 된다.
일단 확인하고 싶으면
이것을 syscall.c 등으로 저장한뒤에
arm-elf-gcc hello.c syscall.c -o hello.o
로 컴파일 해봐라.
아마 될것이다.
그리고 마지막으로
file hello.o
를 해봐서
hello.o: ELF 32-bit LSB executable, ARM, version 1 (ARM), statically linked, not stripped
요런 비스무리한 것으로 뜨면 완전 성공이다..
자축하라
라이브러리 로 만드는건 다음 포스팅에서
다른데 있는거 글거다가 써보겠다.