002-weak_data_fix.patch 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. --- /dev/null
  2. +++ b/gcc/testsuite/gcc.dg/visibility-21.c
  3. @@ -0,0 +1,14 @@
  4. +/* PR target/32219 */
  5. +/* { dg-do run } */
  6. +/* { dg-require-visibility "" } */
  7. +/* { dg-options "-fPIC" { target fpic } } */
  8. +
  9. +extern void f() __attribute__((weak,visibility("hidden")));
  10. +extern int puts( char const* );
  11. +int main()
  12. +{
  13. + if (f)
  14. + f();
  15. + return 0;
  16. +}
  17. +
  18. --- a/gcc/varasm.c
  19. +++ b/gcc/varasm.c
  20. @@ -6677,6 +6677,10 @@ default_binds_local_p_1 (const_tree exp,
  21. /* Static variables are always local. */
  22. else if (! TREE_PUBLIC (exp))
  23. local_p = true;
  24. + /* hidden weak can't be overridden by something non-local, all
  25. + that is possible is that it is not defined at all. */
  26. + else if (DECL_WEAK (exp))
  27. + local_p = false;
  28. /* A variable is local if the user has said explicitly that it will
  29. be. */
  30. else if ((DECL_VISIBILITY_SPECIFIED (exp)
  31. @@ -6690,11 +6694,6 @@ default_binds_local_p_1 (const_tree exp,
  32. local. */
  33. else if (DECL_VISIBILITY (exp) != VISIBILITY_DEFAULT)
  34. local_p = true;
  35. - /* Default visibility weak data can be overridden by a strong symbol
  36. - in another module and so are not local. */
  37. - else if (DECL_WEAK (exp)
  38. - && !resolved_locally)
  39. - local_p = false;
  40. /* If PIC, then assume that any global name can be overridden by
  41. symbols resolved from other modules. */
  42. else if (shlib)