public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* LD: Question about rewriting the function in library
@ 2022-04-15  8:18 夏立方
  2022-04-19 10:14 ` Nick Clifton
  0 siblings, 1 reply; 2+ messages in thread
From: 夏立方 @ 2022-04-15  8:18 UTC (permalink / raw)
  To: binutils


Hi,
There is a simple case here:
a.s
-----------
.section .text.bar
.global bar
bar:
        ret
        .size bar, . - bar

.global foo
.text
.type foo, function
foo:
        call bar
        ret
        .size foo, . - foo
----------
build: ./gas/as -o a.o a.s
AR: ./binutils/as -r liba.a a.o

And the 'main' in b.s will call 'foo', and I want to rewrite function 'bar'
b.s
---------
.global foo
.global bar
.text
bar:
        nop
        nop
        ret
        .size bar, . - bar

.global main
.text
main:
        call foo
        .size main, . - main
----------
build: ./gas/as -o b.o b.s
Link: ./ld/ld-new -o a b.o -L. -la
it will report 'multi define'.
Spliting 'bar' to an other object (c.o) could solve this problem. But the library in the project can't be re-implemented now.
-----------
From my understanding, overriding a function should not be related to other functions in the  same section or in the same object.
So, my question is: Why not use the 'bar' in b.o?

Best Regards,
Lifang







^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-04-19 10:14 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-15  8:18 LD: Question about rewriting the function in library 夏立方
2022-04-19 10:14 ` Nick Clifton

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).