[LLVMdev] Create "appending" section that can be partially dead stripped
Jonas Maebe
jonas.maebe at elis.ugent.be
Tue Aug 5 11:25:50 PDT 2014
On 05/08/14 19:31, Reid Kleckner wrote:
[section start/stop symbols]
> I think you want to declare those [0 x i32] globals instead of defining
> them by adding extern and dropping the empty brackets. Typically they
> are defined by the linker, and not every TU.
In my case, the sections will be unique per compilation unit
(translation unit?). I'm trying to add the start and stop symbols myself
because at least on OS X, the linker doesn't appear to define any such
symbols. Its man page mentions an option called "-sectobjectsymbols",
but it's listed under the obsolete options (on OS X 10.9) and has as
explanation "Adding a local label at a section start is no longer
supported. This option is obsolete."
[C example]
> Speaking of which, I believe both ld.bfd and ld.gold define
> __start_my_section for you, which should make your life easier.
For platforms using the GNU binutils, indeed. My original example was
for Linux/x86-64, but if possible I'd like a solution that does not
depend on the platform or used linker (other than the way how sections
are defined, since e.g. on OS X you also have to specify a segment
name). Maybe the easiest is to consciously just add dummy sentinels. Or
maybe I can add the start and stop labels via module-level inline
assembly...
Thanks,
Jonas
More information about the llvm-dev
mailing list