On 30.04.21 10:03, David Brown wrote:
> On 29/04/2021 21:43, Ian Molton wrote:
> > Hi,
> >
> > I'm attempting to build my project, which does not use libc, or
> > but I do want to link with libgcc.
> >
> > additionally, I don't want any startup code to be linked - the
> > is intended to be fully standalone.
> >
> If you don't use any functions from these libraries, nothing from
> will be linked into your project - it doesn't matter if the linker
has them.

Still dabbling a little with AVR once in a while, I add -nostartfiles
Ian's -nostdlib, to avoid startup code. As my most recent dabble is
-mmcu=attiny2313, with only 1k instructions, any extraneous code bytes
would quickly be noticed.

As for libm, I've always had to -lm that explicitly when needed.

And for libgcc, my makefile remembers better than I, a choice to use
avr-gcc, not just avr-ld for linking on a project which needed libgcc.
That residual choice in the attiny2313 project confirms David's
that stuff is only linked if you use it.


# vim:noexpandtab list foldmethod=manual


CC = avr-gcc
CFLAGS = -g -O2 -nostartfiles -nostdlib -mmcu=attiny2313
AS = /usr/local/avr/bin/avr-as
ASFLAGS = -gstabs -mmcu=attiny2313
LD = /usr/local/avr/bin/avr-ld

# Let avr-gcc link, so it can find libgcc.a:

.SUFFIXES : .c .h .o .s .S

%.o: %.c
   $(CC) -c $(CFLAGS) -o $(OBJDIR)/$@ $<

%.o: %.s
   $(AS) -I$(INC_DIR) $(ASFLAGS) -o $(OBJDIR)/$@ $<

%.o: %.S
   $(CC) -c -I$(INC_DIR) -x assembler-with-cpp $(CFLAGS)
-Wa,-alms=$(OBJDIR)/$@.lst -o $(OBJDIR)/$@ $<

dimmer:  init.o os.o timer.o lamps.o eeprom.o serial.o comms.o
      ( cd $(OBJDIR) ; $(CC) $(LDFLAGS) $(CFLAGS) -o $@.elf $^ >
map )
      avr-objcopy -O srec obj/dimmer.elf -S -R .eeprom
--gap-fill=0xff obj/flash.srec
      avr-objcopy -O ihex obj/dimmer.elf -S -j .eeprom
--gap-fill=0xff obj/eeprom.ihex
      avr-objdump -D obj/$@.elf > obj/dimmer.dump

load:      avrdude -P /dev/ttyUSB0 -p t2313 -c stk500 -e -U
-U eeprom:w:obj/eeprom.ihex

Reply via email to