LLVM Bugzilla is read-only and represents the historical archive of all LLVM issues filled before November 26, 2021. Use github to submit LLVM bugs

Bug 25188 - [elf2] implement __start_SECNAME and __stop_SECNAME
Summary: [elf2] implement __start_SECNAME and __stop_SECNAME
Status: RESOLVED FIXED
Alias: None
Product: lld
Classification: Unclassified
Component: All Bugs (show other bugs)
Version: unspecified
Hardware: PC All
: P normal
Assignee: Unassigned LLVM Bugs
URL:
Keywords:
Depends on:
Blocks: 23214
  Show dependency tree
 
Reported: 2015-10-14 19:41 PDT by Sean Silva
Modified: 2015-10-16 20:52 PDT (History)
5 users (show)

See Also:
Fixed By Commit(s):


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Sean Silva 2015-10-14 19:41:14 PDT
This is required by D13329 (r250200).

In D13329, the following quote from Ian Taylor:

"When a section name is a valid C identifier, the linker automatically provides __start and __stop symbols set to the addresses of the beginning and end of the section.  The symbols are __start_SECNAME and __stop_SECNAME where SECNAME is the name of the section.

This is not defined by the ELF ABI, but it is completely reliable on
GNU/Linux.  In fact it is reliable on any ELF system except possibly
Solaris, and it probably works on Solaris too.  This is definitely
what you should do instead of using a linker script.  It's more
reliable and more efficient, and it's what everybody else does"
Comment 1 Rui Ueyama 2015-10-14 20:01:59 PDT
It should be easy to implement that, but do you know any program that actually uses his feature?
Comment 2 Rui Ueyama 2015-10-14 20:02:50 PDT
Ah, sorry, http://reviews.llvm.org/D13329 is the example as you wrote. I'll try to implement this.
Comment 3 Sean Silva 2015-10-14 20:14:58 PDT
Do you know if Ian is referring to "input sections" or "output sections" when he says "sections"?
Comment 4 Rui Ueyama 2015-10-14 20:36:30 PDT
It seems that "section name" means "output section name". I can link this code with gold, but if I rename input section "foo" to "bar" using linker script, it failed to link because __{start,stop}_foo no longer exist.

.global _start
.text
_start:
        call __start_foo
        call __stop_foo

.section foo,"ax"
        nop
Comment 5 Rui Ueyama 2015-10-14 21:19:27 PDT
http://reviews.llvm.org/D13760
Comment 6 Rui Ueyama 2015-10-15 12:16:16 PDT
Implemented in r250432.