Skip to content

Commit f204057

Browse files
committed
Build {g}crt0.o for each multilib
Although the code is identical, this is needed to get the correct meta-information recorded in elf object files
1 parent 3c97086 commit f204057

File tree

5 files changed

+19
-28
lines changed

5 files changed

+19
-28
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ install-include-recursive install-man-recursive uninstall-lib-recursive \
163163
uninstall-include-recursive uninstall-man-recursive:
164164
@set fnord $(MAKEFLAGS); amf=$$2; \
165165
echo $@ | grep -q install; \
166-
if test $$? = 0 -a "${CROSS}" = yes -a "${prefix}" = "/usr"; then \
166+
if test $$? = 0 -a "${CROSS}" = yes -a "$(DESTDIR)${prefix}" = "/usr"; then \
167167
echo "attempting to install on host; aborting" >&2; \
168168
exit 1; \
169169
fi; \

buildrules

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ pwdgrpdir := $(top_srcdir)/pwdgrp
6060
shadowdir := $(top_srcdir)/shadow
6161
signaldir := $(top_srcdir)/signal
6262
socketdir := $(top_srcdir)/socket
63+
startupdir := $(top_srcdir)/startup
6364
stdiiodir := $(top_srcdir)/stdiio
6465
stdiodir := $(top_srcdir)/stdio
6566
stdlibdir := $(top_srcdir)/stdlib
@@ -143,6 +144,7 @@ DEFS-xnlm_prot.c= -Wno-unused
143144
DEFS-xrstat.c = -Wno-unused
144145
DEFS-xspray.c= -Wno-unused
145146

147+
CRT0OBJS := crt0.o gcrt0.o
146148
ARGPOBJS := $(addsuffix .o, $(basename $(notdir $(ARGPSRCS))))
147149
CRYPTOBJS := $(addsuffix .o, $(basename $(notdir $(CRYPTSRCS))))
148150
DIRENTOBJS := $(addsuffix .o, $(basename $(notdir $(DIRENTSRCS))))
@@ -168,7 +170,7 @@ TERMIOSOBJS := $(addsuffix .o, $(basename $(notdir $(TERMIOSSRCS))))
168170
TIMEOBJS := $(addsuffix .o, $(basename $(notdir $(TIMESRCS))))
169171
TZOBJS := $(addsuffix .o, $(basename $(notdir $(TZSRCS))))
170172
UNIXOBJS := $(addsuffix .o, $(basename $(notdir $(UNIXSRCS))))
171-
OBJS := $(ARGPOBJS) $(CRYPTOBJS) $(DIRENTOBJS) $(GMPOBJS) $(LOGINOBJS) $(MINTLIBOBJS) \
173+
OBJS := $(CRT0OBJS) $(ARGPOBJS) $(CRYPTOBJS) $(DIRENTOBJS) $(GMPOBJS) $(LOGINOBJS) $(MINTLIBOBJS) \
172174
$(MISCOBJS) $(MBYTEOBJS) $(POSIXOBJS) $(PWDGRPOBJS) $(RPCSVCOBJS) $(SHADOWOBJS) \
173175
$(SIGNALOBJS) $(SOCKETOBJS) $(STDIIOOBJS) $(STDIOOBJS) $(STDLIBOBJS) \
174176
$(STRINGOBJS) $(SUNRPCOBJS) $(SYSCALLOBJS) $(SYSVIPCOBJS) $(TERMIOSOBJS) \
@@ -193,7 +195,7 @@ DEP_FILES := $(addprefix $(top_srcdir)/.deps/,$(patsubst %.o,%.P,$(OBJS)))
193195

194196
endif # not top_distdir.
195197

196-
all-here: $(top_srcdir)/CFILES $(top_srcdir)/includepath $(LIBS)
198+
all-here: $(top_srcdir)/CFILES $(top_srcdir)/includepath $(CRT0OBJS) $(LIBS)
197199

198200
$(top_srcdir)/includepath: $(top_srcdir)/configvars
199201
@echo "Generating $@"; \
@@ -275,6 +277,12 @@ vpath %.S $(srcdirs)
275277
.s.o:
276278
$(AM_V_CC)$(COMPILE) -Wp,-MD,$(top_srcdir)/.deps/$(@:.o=.P) -c $< -o $@
277279

280+
crt0.o: $(startupdir)/crt0.S
281+
$(AM_V_CC)$(CC) $(WARN) $(cflags) $(CFLAGS) -nostdinc -I$(top_srcdir)/include -I$(top_srcdir)/mintlib -c $< -o $@
282+
283+
gcrt0.o: $(startupdir)/crt0.S
284+
$(AM_V_CC)$(CC) $(WARN) $(cflags) $(CFLAGS) -nostdinc -I$(top_srcdir)/include -I$(top_srcdir)/mintlib -DGCRT0 -c $< -o $@
285+
278286
# Finally, build the libs.
279287
$(libc): $(LIBCOBJS)
280288
@rm -f $@

checkrules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type=
1515
# If you change this you must run "make checkclean".
1616
cflags=
1717

18-
CRT0 = $(top_srcdir)/startup/crt0.o
18+
CRT0 = $(top_srcdir)/lib$(type)/crt0.o
1919
libs = $(libs-$(@F)) $(top_srcdir)/lib$(type)/libc.a
2020
LIBS = -lgcc $(LIBS-$(@F)) $(libs) -lgcc
2121

rules

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,20 +35,24 @@ baselibs = $(basename $(LIBS))
3535

3636
install-lib:
3737
$(mkinstalldirs) $(DESTDIR)$(libdir)/$(instdir)
38-
@list='$(LIBS)'; for p in $$list; do \
38+
@list='$(LIBS) $(CRT0OBJS)'; for p in $$list; do \
3939
if test -f $$p; then \
4040
echo " $(INSTALL) -m 644 $$p $(libdir)/$(instdir)"; \
4141
$(INSTALL) -m 644 $$p $(DESTDIR)$(libdir)/$(instdir); \
4242
else :; fi; \
4343
done
4444

4545
uninstall-lib:
46-
list='$(baselibs)'; for p in $$list; do \
46+
@list='$(baselibs)'; for p in $$list; do \
4747
r=$$p.a; \
4848
s="$$p"$(libsize).a; \
4949
echo " rm -f $(libdir)/$(instdir)/$$r $(libdir)/$(instdir)/$$s"; \
5050
rm -f $(DESTDIR)$(libdir)/$(instdir)/$$r $(DESTDIR)$(libdir)/$(instdir)/$$s; \
5151
done
52+
@list='$(CRT0OBJS)'; for p in $$list; do \
53+
echo " rm -f $(DESTDIR)$(libdir)/$(instdir)/$$p"; \
54+
rm -f $(DESTDIR)$(libdir)/$(instdir)/$$p; \
55+
done
5256
endif
5357

5458
check: check-recursive

startup/Makefile

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -20,42 +20,21 @@ dont_install_libs = yes
2020
include $(top_srcdir)/configvars
2121
include $(top_srcdir)/bindist
2222

23-
OBJS = crt0.o gcrt0.o
24-
2523
libdir = $(prefix)/lib
2624

2725
INCLUDES = -nostdinc -I$(top_srcdir)/include -I$(top_srcdir)/mintlib
2826

2927
COMPILE = $(CC) $(WARN) $(CFLAGS) $(INCLUDES) $(DEFS)
3028

31-
all-here: $(OBJS)
29+
all-here:
3230

3331
include $(top_srcdir)/phony
3432

35-
crt0.o: $(srcdir)/crt0.S
36-
$(COMPILE) $(INCLUDES) -c $< -o $@
37-
38-
gcrt0.o: $(srcdir)/crt0.S
39-
$(COMPILE) $(INCLUDES) -DGCRT0 -c $< -o $@
40-
4133
include $(top_srcdir)/rules
4234

4335
install: all-here
44-
$(mkinstalldirs) $(DESTDIR)$(libdir)
45-
@list='$(OBJS)'; for p in $$list; do \
46-
if test -f $$p; then \
47-
echo " $(INSTALL) -m 644 $$p $(libdir)"; \
48-
$(INSTALL) -m 644 $$p $(DESTDIR)$(libdir); \
49-
else :; fi; \
50-
done
5136

5237
uninstall:
53-
@list='$(OBJS)'; for p in $$list; do \
54-
if test -f $$p; then \
55-
echo " rm -f $(libdir)/$$p"; \
56-
rm -f $(DESTDIR)$(libdir)/$$p; \
57-
else :; fi; \
58-
done
5938

6039
install-include:
6140

0 commit comments

Comments
 (0)