On Fri, Aug 19, 2016 at 2:32 PM,  <mcg...@kernel.org> wrote:
> From: "Luis R. Rodriguez" <mcg...@kernel.org>
>
> Linux makes extensive use of custom ELF header sections,
> documentation for these are well scatterred. Unify this
> documentation in a central place and provide helpers to
> build custom Linux sections.
>
> This also generalizes sections code to enable avoiding
> modifying the linker scripts when we want to add new
> custom Linux sections. In order to make this generally
> useful we need to ensure all architectures can make use of
> core section helpers but that they can also override should
> this be needed. Instead of relying on section.h this adds
> a sections-core.h since this will be targetted to be safe
> to be used on asm code, linker scripts and C code.
>
> v4:
>
> o Port to shiny new sphinx documentation format
>
> o fix a unicore32 build, turns out this actually fixes unicore32
>   defconfig builds which were failing for a long while. unicore32
>   does not seem to grok well the type passed on a section declaration,
>   this ignores it.
>
> o Use VMLINUX_SYMBOL() in more user symbols (extern C code), not doing
>   this was causing final linker issues with blackfin -- this is
>   a CONFIG_HAVE_UNDERSCORE_SYMBOL_PREFIX=y architecture. The other one
>   being metatag. metatag is not supported on 0-day so I cannot confirm
>   compilation there.
>
> o Added SECTION_CORE() for C code, used later by __LINUX_RANGE()
>
> o Since SECTION_CORE() is defined for linker script and C code, share
>   the same helper and just use a __stringify() for the C code as is done
>   for the other C helpers.
>
> o move generic sections to asm-generic/section-core.h instead.
>   PowerPC compilation blows up if asm/jump_labels.h gets
>   section.h included, fixing this is not in any way easy.
>   The list of issues are endless. Moving new data to a new
>   simple file resolves this.
>
> o since things are now in asm-generic/section-core.h the
>   guard changes on asm-generic/sections.h and each architecture
>   sections.h are no longer needed
>
> o Give generic sections some maintainer love, that change is
>   Acked-by Arnd Bergmann, Josh and hpa.
>
> o A few checkpatch.pl style fixes
>
> o As suggested by James Hogan use generic-y to copy generic
>   header files on architectures that do not have a sections.h
>   instead of writing a simple file only to include the generic one.
>
> v3:
>
> o add missing sections.h for architectures that did not
>   have it
>
> o move generic sections to asm-generic/sections.h
>
> o add generic asm helpers section_type(), section_type_asmtype(),
>   push_section_type() -- these helpers enable easy use for
>   for later declaring and using of custom linux sections using
>   more standard APIs in both C code, asm code (C asm calls, or
>   asm files), enabling future standardized section types to
>   be more immediately accessible to asm code, not just C code.
>   Note for ASM_CMD_SEP we use by default "\n", architectures needed
>   to override can do so on their own sections.h prior to inclusion
>   of asm-generic/sections.h
>
> Signed-off-by: Luis R. Rodriguez <mcg...@kernel.org>
> ---
>  Documentation/index.rst                   |   1 +
>  Documentation/sections/conf.py            |   4 +
>  Documentation/sections/index.rst          |  11 +
>  Documentation/sections/section-core.rst   | 153 ++++++++++++++
>  MAINTAINERS                               |  14 ++
>  arch/alpha/include/asm/Kbuild             |   1 +
>  arch/arc/include/asm/Kbuild               |   1 +
>  arch/arm/include/asm/Kbuild               |   1 +
>  arch/arm64/include/asm/Kbuild             |   1 +
>  arch/avr32/include/asm/Kbuild             |   1 +
>  arch/blackfin/include/asm/Kbuild          |   1 +
>  arch/c6x/include/asm/Kbuild               |   1 +
>  arch/cris/include/asm/Kbuild              |   1 +
>  arch/frv/include/asm/Kbuild               |   1 +
>  arch/h8300/include/asm/Kbuild             |   1 +
>  arch/hexagon/include/asm/Kbuild           |   1 +
>  arch/ia64/include/asm/Kbuild              |   1 +
>  arch/m32r/include/asm/Kbuild              |   1 +
>  arch/m68k/include/asm/Kbuild              |   1 +
>  arch/metag/include/asm/Kbuild             |   1 +
>  arch/microblaze/include/asm/Kbuild        |   1 +
>  arch/mips/include/asm/Kbuild              |   1 +
>  arch/mn10300/include/asm/Kbuild           |   1 +
>  arch/nios2/include/asm/Kbuild             |   1 +
>  arch/openrisc/include/asm/Kbuild          |   1 +
>  arch/parisc/include/asm/Kbuild            |   1 +
>  arch/powerpc/include/asm/Kbuild           |   1 +
>  arch/s390/include/asm/Kbuild              |   1 +
>  arch/score/include/asm/Kbuild             |   1 +
>  arch/sh/include/asm/Kbuild                |   1 +
>  arch/sparc/include/asm/Kbuild             |   1 +
>  arch/tile/include/asm/Kbuild              |   1 +
>  arch/um/include/asm/Kbuild                |   1 +
>  arch/unicore32/include/asm/section-core.h |  19 ++
>  arch/x86/include/asm/Kbuild               |   1 +
>  arch/xtensa/include/asm/Kbuild            |   1 +
>  include/asm-generic/section-core.h        | 341 
> ++++++++++++++++++++++++++++++
>  include/asm-generic/sections.h            |   2 +
>  include/asm-generic/vmlinux.lds.h         |  27 +--
>  include/linux/sections.h                  | 111 ++++++++++
>  40 files changed, 700 insertions(+), 13 deletions(-)
>  create mode 100644 Documentation/sections/conf.py
>  create mode 100644 Documentation/sections/index.rst
>  create mode 100644 Documentation/sections/section-core.rst
>  create mode 100644 arch/unicore32/include/asm/section-core.h
>  create mode 100644 include/asm-generic/section-core.h
>  create mode 100644 include/linux/sections.h
>
> diff --git a/Documentation/index.rst b/Documentation/index.rst
> index a15f81855b39..10c9b867e326 100644
> --- a/Documentation/index.rst
> +++ b/Documentation/index.rst
> @@ -14,6 +14,7 @@ Contents:
>     kernel-documentation
>     media/index
>     gpu/index
> +   sections/index
>
>  Indices and tables
>  ==================
> diff --git a/Documentation/sections/conf.py b/Documentation/sections/conf.py
> new file mode 100644
> index 000000000000..faa1c57595e1
> --- /dev/null
> +++ b/Documentation/sections/conf.py
> @@ -0,0 +1,4 @@
> +# -*- coding: utf-8; mode: python -*-
> +
> +project = 'Linux Kernel ELF sections'
> +html_search_language = 'en'
> diff --git a/Documentation/sections/index.rst 
> b/Documentation/sections/index.rst
> new file mode 100644
> index 000000000000..d411e9b22eb3
> --- /dev/null
> +++ b/Documentation/sections/index.rst
> @@ -0,0 +1,11 @@
> +=========================
> +Linux Kernel ELF sections
> +=========================
> +
> +This book documents the Linux kernel's use of ELF sections, as well as 
> helpers
> +used throughout the kernel to help declare and define them.
> +
> +.. toctree::
> +   :maxdepth: 4
> +
> +   section-core
> diff --git a/Documentation/sections/section-core.rst 
> b/Documentation/sections/section-core.rst
> new file mode 100644
> index 000000000000..ecf4228bc4f8
> --- /dev/null
> +++ b/Documentation/sections/section-core.rst
> @@ -0,0 +1,153 @@
> +==============================
> +Core Linux kernel ELF sections
> +==============================
> +
> +About
> +=====
> +
> +This book documents the different standard and custom ELF sections used
> +on the Linux kernel, which we refer to as the ``core Linux sections``. We
> +start off by documenting the standard ELF sections used by Linux and move
> +on to the basic custom ELF sections, followed by a set of helpers. Each
> +section documented describes the goal of the section, and addresses
> +concurrency considerations when applicable.
> +
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: Custom linker script
> +
> +Standard ELF section use in Linux
> +=================================
> +
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: Standard ELF section use in Linux
> +
> +SECTION_RODATA
> +--------------
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: SECTION_RODATA
> +
> +SECTION_RODATA

Typo: should this be called SECTION_TEXT instead?

> +--------------
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: SECTION_TEXT
> +
> +SECTION_DATA
> +------------
> +.. kernel-doc:: include/asm-generic/section-core.h
> +   :doc: SECTION_DATA

Missing from this list are things like the __read_mostly
(".data..read_mostly") and __ro_after_init (".data..ro_after_init")
sections. Should those be included too, or are you only doing the "top
level" sections?

-Kees

-- 
Kees Cook
Nexus Security

_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel

Reply via email to