This is the mail archive of the newlib@sourceware.org mailing list for the newlib project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH 3/3, newlib] Allow locking routine to be retargeted




On 01/02/17 09:06, Freddie Chopin wrote:
On Tue, 2017-01-31 at 17:19 +0000, Thomas Preudhomme wrote:
 > 1. Why is the lock used by at_quick_exit() not required - I have
no
 > idea. The linking error (when I do not provide storage for this
lock)
 > about multiple definitions is visible only when I actually use the
 > at_quick_exit() function.

That makes sense. If you don't use at_quick_exit then probably no
symbol in the
corresponding object file is referenced and therefore the file is not
linked in.
That's exactly why the "doubly defined error on missing symbol" work
as
explained in the cover letter: file with dummy symbol is only linked
in if it
solves an undefined reference.

This case seems a bit different, as it applies only to the
at_quick_exit() lock. In my code I have no references to "env" or "tz"
locks either, but I cannot drop these objects without the "multiple
definitions" error. Maybe my test is flawed, but browsing the assembly
output does not show any uses of __tz_lock(), __tz_unlock(),
__env_lock() or __env_unlock() functions (which are not present in the
output file), and these are the only places of newlib which use this
particular locks. I'll try later with a simpler project.

Your code don't need to reference the env or tz lock directly for them to be linked in. The linker does a transitive closure of files until all references are resolved. So you code could reference a function a() present in a file A.o with that file containing references to function b() in file B.o which contains reference to tz_lock in file tz_lock.o which also contains the tz_mutex lock.

If you show me a small testcase where tz_lock or the env lock cannot be removed I can tell you why does the error happens.

Best regards,

Thomas


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]