Previously we had incorrect logic here. Imagine we would have the next script:
LIBSAMPLE_1.0 { global: a_2; local: *; }; LIBSAMPLE_2.0 { global: a*; };
According to previous logic it would assign version 1 to a_2 and then
would try to reassign it to version 2 because of applying wildcard a*.
And show a warning about that.
Generally Ian Lance Tailor wrote about next rules that should be applied:
(http://www.airs.com/blog/archives/300)
Here are the current rules for gold:
- If there is an exact match for the mangled name, we use it.
If there is more than one exact match, we give a warning, and we use the first tag in the script which matches.
If a symbol has an exact match as both global and local for the same version tag, we give an error.
- Otherwise, we look for an extern C++ or an extern Java exact match. If we find an exact match, we use it.
If there is more than one exact match, we give a warning, and we use the first tag in the script which matches.
If a symbol has an exact match as both global and local for the same version tag, we give an error.
- Otherwise, we look through the wildcard patterns, ignoring “*” patterns. We look through the version tags in reverse order. For each version tag, we look through the global patterns and then the local patterns. We use the first match we find (i.e., the last matching version tag in the file).
- Otherwise, we use the “*” pattern if there is one. We give a warning if there are multiple “*” patterns.
Patch makes wildcard matching to be in revered order and to follow after the regular naming matching.
This function should probably be inlined to the place where you call it because non-wildcard patterns and wildcard patterns shares less code. For example, you don't need to call findAll for non-wildcards (but instead you want to call find). You don't want to issue a warning if non-wildcards. So this function is not actually common code for both cases.