Re: [PATCH] Fix attribute((section)) for templates

2019-11-29 Thread Strager Neds
)) to allow specifying different section names for different section flags. Thanks in advance for your feedback! On Fri, Nov 22, 2019 at 12:09 PM Strager Neds wrote: > > Here's a revised version of the patch. This revised version is ready for > review. > > When GCC encounters _

Re: [PATCH] Fix attribute((section)) for templates

2019-11-22 Thread Strager Neds
Here's a revised version of the patch. This revised version is ready for review. When GCC encounters __attribute__((section("foo"))) on a function or variable declaration, it adds an entry in the symbol table for the declaration to remember its desired section. The symbol table is separate from th

[PATCH] Fix attribute((section)) with -flto

2019-11-20 Thread Strager Neds
When building an executable with LTO, GCC effectively ignores __attribute__((section)) on C++ inline member functions. Moving such functions into the .text section seems to be intentional, but I think ignoring the section attribute is unintentional: https://gcc.gnu.org/ml/gcc-patches/2010-07/msg00

[PATCH] Simplify testing symbol sections

2019-11-20 Thread Strager Neds
While fixing some bugs in __attribute__((section)), I found it difficult to write tests. Make testing easier: introduce the scan-assembler-symbol-section and scan-symbol-section helpers. See in-line documentation for details. Testing: * Run `make check` on x86_64-linux-gnu with --disable-multilib

[PATCH] Fix libstdc++ build on macOS

2019-11-13 Thread Strager Neds
Bootstrap-building libstdc++ on macOS Sierra 10.12.6 (x86_64-apple-darwin16.7.0) fails with the following linker error: Undefined symbols for architecture x86_64: "__ZSt15__alloc_on_copyISaIcEEvRT_RKS1_", referenced from: __ZNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE6a

[PATCH 3/3] Improve efficiency of copying section from another tree

2019-11-12 Thread Strager Neds
Several parts of GCC need to copy a section name from one tree (or symtab_node) to another. Currently, this is implemented naively: 1. Query the source's section name 2. Hash the section name string 3. Find the section_hash_entry in the symbol table 4. Increment the section_hash_entry's reference

[PATCH 2/3] Refactor section name ref counting

2019-11-12 Thread Strager Neds
symtab_node::set_section_for_node manages the reference count of section_hash_entry objects. I plan to add another function which needs to manage the reference count of these objects. To avoid duplicating code, factor the existing logic into reusable functions. This patch should not change behavio

[PATCH 1/3] Refactor copying decl section names

2019-11-12 Thread Strager Neds
Sometimes, we need to copy a section name from one decl or symtab node to another. Currently, this is done by getting the source's section name and setting the destination's section name. For example: set_decl_section_name (dest, DECL_SECTION_NAME (source)); dest->set_section (source->get_

Re: [PATCH] Fix attribute((section)) for templates

2019-11-06 Thread Strager Neds
, 2019 at 3:38 PM Strager Neds wrote: > > Aside: This is my first time working in GCC's code base. I probably made > some mistakes. Please point them out. =] > > When GCC encounters __attribute__((section("foo"))) on a function or > variable declaration, it adds an

[PATCH] Fix attribute((section)) for templates

2019-11-05 Thread Strager Neds
Aside: This is my first time working in GCC's code base. I probably made some mistakes. Please point them out. =] When GCC encounters __attribute__((section("foo"))) on a function or variable declaration, it adds an entry in the symbol table for the declaration to remember its desired section. The