helper.mk 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. #
  2. # Copyright (C) 2012 Marek Vasut <marex@denx.de>
  3. #
  4. # See file CREDITS for list of people who contributed to this
  5. # project.
  6. #
  7. # This program is free software; you can redistribute it and/or
  8. # modify it under the terms of the GNU General Public License as
  9. # published by the Free Software Foundation; either version 2 of
  10. # the License, or (at your option) any later version.
  11. #
  12. #########################################################################
  13. ##
  14. # make_u_boot_list - Generate contents of u_boot_list section
  15. # 1: The name of the resulting file (usually u-boot.lst)
  16. # 2: Files to analyze for possible u_boot_list entries
  17. #
  18. # This function generates the contents of the u_boot_list section,
  19. # including all the border symbols for it's subsections. The operation
  20. # of this function is as follows, numbering goes per lines:
  21. #
  22. # 1) Dump the ELF header sections from all files supplied via $(2)
  23. # 2) Filter out all other stuff that does not belong into .u_boot_list
  24. # section.
  25. # 3) Fix up the lines so that the resulting output is is in format
  26. # ".u_boot_list.*".
  27. # 4) Remove the last .something$, since that only contains the name
  28. # of the variable to be put into a subsection. This name is irelevant
  29. # for generation of border symbols, thus of no interest, remove it.
  30. # 5) Take each line and for every dot "." in that line, print the whole
  31. # line until that dot "." . This is important so that we have all
  32. # parent border symbols generated as well.
  33. # 6) Load every line and firstly append "\a" at the end and print the
  34. # line. Next, append "@" at the end and print the line. Finally,
  35. # append "~" at the end of line. This will make sense in conjunction
  36. # with 6) and 7).
  37. # 7) Sort the lines. It is imperative to use LC_COLLATE=C here because
  38. # with this, the "\a" symbol is first and "~" symbol is last. Any
  39. # other symbols fall inbetween. Symbols like "@", which marks the
  40. # end of current line (representing current section) and ".", which
  41. # means the line continues and thus represents subsection.
  42. # 8) With such ordering, all lines ending with "\a" will float at the
  43. # begining of all lines with the same prefix. Thus it is easy to
  44. # replace "\a" with __start and make it the __start border symbol.
  45. # Very similarly for "~", which will be always at the bottom and so
  46. # can be replaced by "__end" and made into the __end border symbol.
  47. # Finally, every line ending with "@" symbol will be transformed
  48. # into " *(SORT(${line}*)); " format, which in the linker parlance
  49. # will allow it to trap all symbols relevant to the subsection.
  50. #
  51. define make_u_boot_list
  52. $(1): $(2)
  53. $(OBJDUMP) -h $(2) | \
  54. sed -n -e '/.*\.u_boot_list[^ ]\+/ ! {d;n}' \
  55. -e 's/.*\(\.u_boot_list[^ ]\+\).*$$$$/\1/' \
  56. -e 's/\.[^\.]\+$$$$//' \
  57. -e ':s /^.\+$$$$/ { p;s/^\(.*\)\.[^\.]*$$$$/\1/;b s }' | \
  58. sed -n -e 'h;s/$$$$/\a/p;g;s/$$$$/@/p;g;s/$$$$/~/p;' | \
  59. LC_COLLATE=C sort -u | \
  60. sed -n -e '/\a$$$$/ { s/\./_/g;s/\a$$$$/__start = .;/p; }'\
  61. -e '/~$$$$/ { s/\./_/g;s/~$$$$/__end = .;/p; }'\
  62. -e '/@$$$$/ { s/\(.*\)@$$$$/*(SORT(\1.*));/p }' > $(1)
  63. endef