Skip to contentSkip to conversation

at91: use pre-built object to avoid weak function problem

PATCH New Jean-Christophe PLAGNIOL-VILLARD 3 participants 8 messages Feb 1, 2009 – Feb 4, 2009

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 at91: use pre-built object to avoid weak function problem

add weak lowlel_init

---
 config.mk                          |    3 +++
 cpu/arm926ejs/at91/Makefile        |    2 +-
 cpu/arm926ejs/at91/lowlevel_init.S |    2 ++
 3 files changed, 6 insertions(+), 1 deletions(-)
config.mk +3 -0
index b1254e9..94b8c7c 100644
@@ -76,6 +76,9 @@ STRIP	= $(CROSS_COMPILE)strip
 OBJCOPY = $(CROSS_COMPILE)objcopy
 OBJDUMP = $(CROSS_COMPILE)objdump
 RANLIB	= $(CROSS_COMPILE)RANLIB
+cmd_link_o_target = $(if $(strip $(2)),\
+			$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+			rm -f $@; $(AR) rcs $(1))
 
 #########################################################################
 
cpu/arm926ejs/at91/Makefile +1 -1
index 2d2a888..662657c 100644
@@ -36,7 +36,7 @@ OBJS    := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
 all:	$(obj).depend $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $@, $(OBJS))
 
 #########################################################################
 
cpu/arm926ejs/at91/lowlevel_init.S +2 -0
index ec6ad5d..54b3f3d 100644
@@ -30,6 +30,8 @@
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 
 .globl lowlevel_init
+.weak lowlevel_init
+.set lowlevel_init,function
 lowlevel_init:
 
 	/*
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 1/1 at91: use pre-built object to avoid weak function problem

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 1 line · In message <[email protected]> you wrote:

add weak lowlel_init

What does "lowlel" mean?

You definitely want to add a more descriptive comment here waht you are doing, why you are doing it, and why you are doing it this way.

Quoted 12 lines
---
 config.mk                          |    3 +++
 cpu/arm926ejs/at91/Makefile        |    2 +-
 cpu/arm926ejs/at91/lowlevel_init.S |    2 ++
 3 files changed, 6 insertions(+), 1 deletions(-)
config.mk +0 -0
index b1254e9..94b8c7c 100644

config.mk STRIP = $(CROSS_COMPILE)strip · line 81

Quoted 6 lines
config.mk +3 -0
@@ -76,6 +76,9 @@ STRIP	= $(CROSS_COMPILE)strip
 OBJCOPY = $(CROSS_COMPILE)objcopy
 OBJDUMP = $(CROSS_COMPILE)objdump
 RANLIB	= $(CROSS_COMPILE)RANLIB
+cmd_link_o_target = $(if $(strip $(2)),\
+			$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+			rm -f $@; $(AR) rcs $(1))

Please make sure to use $(STRIP) instead of 'strip', and $ARFLAGS) instead of 'rcs'

Quoted 20 lines
config.mk +0 -0
 #########################################################################
 
cpu/arm926ejs/at91/Makefile +1 -1
index 2d2a888..662657c 100644
@@ -36,7 +36,7 @@ OBJS    := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
 all:	$(obj).depend $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $@, $(OBJS))
 
 #########################################################################
 
cpu/arm926ejs/at91/lowlevel_init.S +0 -0
index ec6ad5d..54b3f3d 100644

cpu/arm926ejs/at91/lowlevel_init.S line 35

Quoted 6 lines
cpu/arm926ejs/at91/lowlevel_init.S +2 -0
@@ -30,6 +30,8 @@
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 
 .globl lowlevel_init
+.weak lowlevel_init
+.set lowlevel_init,function
 lowlevel_init:

If this change is needed for AT91 only, then cmd_link_o_target should not be added to the global config.mk - why not add it to cpu/arm926ejs/at91/config.mk ?

Best regards,

Wolfgang Denk

Signature · 4 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Diplomacy is the art of saying "nice doggy" until you can find a rock.
#2 lore raw

PATCH 1/1 at91: use pre-built object to avoid weak function problem

Quoted 6 lines · Wolfgang Denk

config.mk STRIP = $(CROSS_COMPILE)strip · line 81

Quoted 3 lines · In message Jean-Christophe PLAGNIOL-VILLARD you
config.mk +3 -0
+cmd_link_o_target = $(if $(strip $(2)),\
+                     $(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+                     rm -f $@; $(AR) rcs $(1))

Please make sure to use $(STRIP) instead of 'strip'

this is make $(strip ...), not toolchain $(STRIP)
-mike

#3 lore raw

PATCH 1/1 at91: use pre-built object to avoid weak function problem

Dear Mike Frysinger,

Quoted 8 lines · In message <[email protected]> you…
Quoted 6 lines

config.mk STRIP = $(CROSS_COMPILE)strip · line 81

Quoted 4 lines
config.mk +3 -0
+cmd_link_o_target = $(if $(strip $(2)),\
+                     $(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+                     rm -f $@; $(AR) rcs $(1))

Please make sure to use $(STRIP) instead of 'strip'

this is make $(strip ...), not toolchain $(STRIP)

Please elucidate?

Best regards,

Wolfgang Denk

Signature · 6 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
When a man sits with a pretty girl for  an  hour,  it  seems  like  a
minute.  But let him sit on a hot stove for a minute -- and it's lon-
ger than any hour. That's relativity.              -- Albert Einstein
#4 lore raw

PATCH 1/1 at91: use pre-built object to avoid weak function problem

Quoted 10 lines · Wolfgang Denk
Quoted 7 lines · In message Mike Frysinger you
Quoted 5 lines

config.mk STRIP = $(CROSS_COMPILE)strip · line 81

Quoted 3 lines
config.mk +3 -0
+cmd_link_o_target = $(if $(strip $(2)),\
+                     $(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+                     rm -f $@; $(AR) rcs $(1))

Please make sure to use $(STRIP) instead of 'strip'

this is make $(strip ...), not toolchain $(STRIP)

Please elucidate?

http://www.gnu.org/software/make/manual/html_node/Text-Functions.html#Text-Functions
-mike

#5 lore raw

PATCH 1/1 at91: use pre-built object to avoid weak function problem

Dear Mike Frysinger,

Quoted 6 lines · In message <[email protected]> you…
Quoted 5 lines · Wolfgang Denk
Quoted 4 lines · In message Mike Frysinger you
Quoted 4 lines
Quoted 3 lines
config.mk +3 -0
+cmd_link_o_target = $(if $(strip $(2)),\
+                     $(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+                     rm -f $@; $(AR) rcs $(1))
Quoted 7 lines
Quoted 5 lines
Quoted 3 lines
Quoted 1 line

Please make sure to use $(STRIP) instead of 'strip'

this is make $(strip ...), not toolchain $(STRIP)

Please elucidate?

http://www.gnu.org/software/make/manual/html_node/Text-Functions.html#Text-Functions

I see. Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Violence in reality is quite different from theory.
	-- Spock, "The Cloud Minders", stardate 5818.4
#6 lore raw

PATCH v2 1/1 at91: allow the lowlevel_init to be overwrite by the board

In reply to Jean-Christophe PLAGNIOL-VILLARD

due to asm weak function link overwrite problem use pre-built object instead of library.

You will need to build the lib$(BOARD).a the same way

---
The asm weak overwrite link problem have been found also present on other arm And supposed on other arch

the the AR do not use the $(ARFLAGS) because in this case we will have no file as param to generate the library

Best Regards,
J.

 config.mk                          |    3 +++
 cpu/arm926ejs/at91/Makefile        |    2 +-
 cpu/arm926ejs/at91/lowlevel_init.S |    2 ++
 3 files changed, 6 insertions(+), 1 deletions(-)
config.mk +3 -0
index b1254e9..94b8c7c 100644
@@ -76,6 +76,9 @@ STRIP	= $(CROSS_COMPILE)strip
 OBJCOPY = $(CROSS_COMPILE)objcopy
 OBJDUMP = $(CROSS_COMPILE)objdump
 RANLIB	= $(CROSS_COMPILE)RANLIB
+cmd_link_o_target = $(if $(strip $(2)),\
+			$(LD) $(PLATFORM_LDFLAGS) -r -o $(1) $(2) ,\
+			rm -f $@; $(AR) rcs $(1))
 
 #########################################################################
 
cpu/arm926ejs/at91/Makefile +1 -1
index 2d2a888..662657c 100644
@@ -36,7 +36,7 @@ OBJS    := $(addprefix $(obj),$(SOBJS) $(COBJS-y))
 all:	$(obj).depend $(LIB)
 
 $(LIB):	$(OBJS)
-	$(AR) $(ARFLAGS) $@ $(OBJS)
+	$(call cmd_link_o_target, $@, $(OBJS))
 
 #########################################################################
 
cpu/arm926ejs/at91/lowlevel_init.S +2 -0
index ec6ad5d..54b3f3d 100644
@@ -30,6 +30,8 @@
 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
 
 .globl lowlevel_init
+.weak lowlevel_init
+.set lowlevel_init,function
 lowlevel_init:
 
 	/*
Signature · 1 line
1.5.6.5
#7 lore raw

PATCH v2 1/1 at91: allow the lowlevel_init to be overwrite by the board

Dear Jean-Christophe PLAGNIOL-VILLARD,

Quoted 2 lines · In message <[email protected]> you wrote:

due to asm weak function link overwrite problem use pre-built object instead of library.

Or use a correct linker script that makes sure the needed objects get pulled in by the linker before it attempts to resolve references from the libraries.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Killing is wrong.
	-- Losira, "That Which Survives", stardate unknown