[PATCH] D39548: [ELF] Set the section size on the section start symbols

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 7 04:43:47 PST 2017


peter.smith added a comment.

> Currently we generate a special ELF section `__cap_relocs` containing a capability "relocations" for every global pointer.  For historic reasons we don't use ELF relocations but an array of structs that is processed by crt_init_globals() <https://github.com/CTSRD-CHERI/cheribsd/blob/master/lib/csu/cheri/crt1.c#L96> in the initial startup code.
>  This separate section also has the advantage that we don't need any symbol tables at runtime but can just loop over this array containing addresses resolved at static link time.
>  We need sizes on every ELF symbol that can be used as a pointer in order to set the correct runtime-bounds on the resulting capability so that we can find all bounds violations.

Thanks for the detailed answer. Does the static linker create the __cap_relocs section, or is it some standalone tool? If it is the static linker itself, then presumably there could be alternative ways of obtaining the size for the capability that would not involve propagating the change into the symbol table. For example set a flag on the symbol definition so that when you are writing out the __cap_relocs and encounter a flagged symbol with size 0, you can calculate it from the OutputSection. Not as elegant for the __cap_relocs section but it might be ok to upstream the flagging mechanism?


https://reviews.llvm.org/D39548





More information about the llvm-commits mailing list