Linking error/Makefile bug

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I still seem to run in to trouble with compilation/linking/Makefiles basics. It would be great if someone could clear this problem I am facing.

I have written this Makefile which uses a cross-complier/linker (for arm). Now when I do a  "make" the executable image is formed but it contains all undefined symbols.

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
#Makefile for the user space test driver application

TESTDIR = $(shell cd ../;pwd)
CC = xscale_le-gcc
LD = xscale_le-ld
LIB := /opt/montavista/pro/devkit/arm/xscale_le/lib/gcc-lib/armv5tel-hardhat-linux/3.3.1
INCLUDE := $(TESTDIR)

CFLAGS += -Wall -I$(INCLUDE)

TARGET = user_app
SRC := uapp.c parse_opts.c
OBJS := parse_opts.o uapp.o #uapp.c uses symbols defined in parse_opts.c

all : .depend $(TARGET)

$(TARGET) : $(OBJS)
    $(LD) -r -L$(LIB) -lgcc $^ -o $@

$(OBJS) : $(SRC)
    $(CC) $(CFLAGS) -c $(SRC)

install:
    mv -f $(TARGET) bin/

clean :
    rm -f *.o *.*~ .depend $(TARGET)

depend .depend :
    $(CC) $(CFLAGS) -M *.c > $@

include .depend
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++=
 Now when I do a objdump, many symbols seem to be unresolved. So, obviously the linking dosent seem to be done properly.
(ps: when I do the compilation and linking in a single step, i.e., it gets linked properly)

+++++++++++++++++++++++++++++++++++++++++++++++++++
$objdump -t prog

user_app:     file format elf32-little

SYMBOL TABLE:
00000000 l    d  .text    00000000
00000000 l    d  *ABS*    00000000
00000000 l    d  .rodata    00000000
00000000 l    d  *ABS*    00000000
00000000 l    d  .data    00000000
00000000 l    d  .bss    00000000
00000000 l    d  .comment    00000000
00000000 l    d  *ABS*    00000000
00000000 l    d  *ABS*    00000000
00000000 l    d  *ABS*    00000000
00000000 l    df *ABS*    00000000 parse_opts.c
00000000 l    df *ABS*    00000000 uapp.c
00000000         *UND*    00000000 strcpy
00000000         *UND*    00000000 ioctl
00000000         *UND*    00000000 printf
00000000         *UND*    00000000 getopt_long
00000000 g     F .text    00000284 ParseOpts
000004b8 g     F .text    0000001c PrintUsage
00000000         *UND*    00000000 memcpy
00000284 g     F .text    00000234 GetArgs
00000000         *UND*    00000000 perror
000007a0 g     F .text    000000d0 Print_DataStruct
00000000         *UND*    00000000 malloc
00000000         *UND*    00000000 optarg
00000724 g     F .text    0000007c Cleanup
00000014       O *COM*    00000020 data
000004d4 g     F .text    00000250 main
00000000         *UND*    00000000 exit
00000000         *UND*    00000000 atoi
00000000         *UND*    00000000 strlen
00000000         *UND*    00000000 open
00000000         *UND*    00000000 free
+++++++++++++++++++++++++++++++++++++++++++++++++++++

Can someone please give pointers as to what is the bug in this Makefile ?
rgds
Arun



--
"There are 10 people in the world - those who understand binary and those who dont !"

[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux