New user self-registration is disabled due to spam. For an account please email bugs-admin@lists.llvm.org with your e-mail address and full name.

Bug 42950 - __attribute__((section())) string should not be escaped
Summary: __attribute__((section())) string should not be escaped
Status: RESOLVED WONTFIX
Alias: None
Product: clang
Classification: Unclassified
Component: C (show other bugs)
Version: trunk
Hardware: PC Linux
: P enhancement
Assignee: Unassigned Clang Bugs
URL:
Keywords:
Depends on:
Blocks: 4068
  Show dependency tree
 
Reported: 2019-08-09 14:33 PDT by Nick Desaulniers
Modified: 2020-09-29 11:55 PDT (History)
10 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 Nick Desaulniers 2019-08-09 14:33:07 PDT
int foo __attribute__((__section__("\".foo\"")));


In Clang produces:
  .section "\".foo\"","aw",@progbits

In GCC:
  .section ".foo","aw"

This is leading to a bug in Clang built Linux kernels for distros that use BPF (not eBPF) during boot, causing them to fail to boot.

https://github.com/ClangBuiltLinux/linux/issues/619
Comment 1 Nick Desaulniers 2019-08-09 14:34:44 PDT
We can work around this for now; the escaping is coming from use of the C preprocessor:

#define __section(S) __attribute__((__section__(#S)))
int foo __section(".foo")

can instead be:
int foo __section(.foo)

but this is still a bug (or at least a dependency from gcc/binutils).
Comment 2 Reid Kleckner 2019-08-09 14:51:30 PDT
Coincidentally, I mentioned this exact GCC misfeature to Bob yesterday. This has come up in the past, and our stance then was that this was always an escaping bug that GCC should fix. Previously people used to use this in creative ways to change the protections of the section, but I don't think it is possible anymore, at least not without using the comment character.
Comment 3 Kees Cook 2019-08-09 19:12:16 PDT
(In reply to Reid Kleckner from comment #2)
> Coincidentally, I mentioned this exact GCC misfeature to Bob yesterday. This
> has come up in the past, and our stance then was that this was always an
> escaping bug that GCC should fix. Previously people used to use this in
> creative ways to change the protections of the section, but I don't think it
> is possible anymore, at least not without using the comment character.

As a person that has tried to use that hack, it is highly unstable and not cross-architecture portable, and should not be used. :P
Comment 4 Nick Desaulniers 2020-09-29 11:55:27 PDT
Marking WONTFIX based on Reid's comment.