bfin-libgcc-mkmap-symver-support-skip_underscore.patch 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. From ae9c3e354440c4a0f105a9eabfb2f77be085ebc1 Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Thu, 18 Aug 2016 17:59:16 +0200
  4. Subject: [PATCH] libgcc/mkmap-symver: support skip_underscore
  5. Some platforms, such as Blackfin, have a special prefix for assembly
  6. symbols as opposed to C symbols. For this reason, a function named
  7. "foo()" in C will in fact be visible as a symbol called "_foo" in the
  8. ELF binary.
  9. The current linker version script logic in libgcc doesn't take into
  10. account this situation properly. The Blackfin specific
  11. libgcc/config/bfin/libgcc-glibc.ver has an additional "_" in front of
  12. every symbol so that it matches the output of "nm" (which gets parsed to
  13. produce the final linker version script). But due to this additional
  14. "_", ld no longer matches with the symbols since "ld" does the matching
  15. with the original symbol name, not the one prefixed with "_".
  16. Due to this, none of the symbols in libgcc/config/bfin/libgcc-glibc.ver
  17. are actually matched with symbols in libgcc. This causes all libgcc
  18. symbols to be left as "LOCAL", which causes lots of "undefined
  19. reference" whenever some C or C++ code that calls a function of libgcc
  20. is compiled.
  21. To address this, this commit introduces a "skip_underscore" variable to
  22. the mkmap-symver script. It tells mkmap-symver to ignore the leading
  23. underscore from the "nm" output.
  24. Note that this new argument is different from the existing
  25. "leading_underscore" argument, which *adds* an additional underscore to
  26. the generated linker version script.
  27. Having this functionality paves the way to using the generic linker
  28. version information for Blackfin, instead of using a custom one.
  29. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  30. ---
  31. libgcc/mkmap-symver.awk | 6 +++++-
  32. 1 file changed, 10 insertions(+), 1 deletion(-)
  33. diff --git a/libgcc/mkmap-symver.awk b/libgcc/mkmap-symver.awk
  34. index 266832a..30bb179 100644
  35. --- a/libgcc/mkmap-symver.awk
  36. +++ b/libgcc/mkmap-symver.awk
  37. @@ -47,7 +47,11 @@ state == "nm" && ($1 == "U" || $2 == "U") {
  38. state == "nm" && NF == 3 {
  39. split ($3, s, "@")
  40. - def[s[1]] = 1;
  41. + if (skip_underscore)
  42. + symname = substr(s[1], 2);
  43. + else
  44. + symname = s[1];
  45. + def[symname] = 1;
  46. sawsymbol = 1;
  47. next;
  48. }
  49. --
  50. 2.7.4