Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dredd could still inject headers before Feature Test Macros #302

Closed
JonathanFoo0523 opened this issue Jul 17, 2024 · 3 comments
Closed

Dredd could still inject headers before Feature Test Macros #302

JonathanFoo0523 opened this issue Jul 17, 2024 · 3 comments

Comments

@JonathanFoo0523
Copy link
Collaborator

As an example, consider this adaptation from #215 (addressed by #220 )

void bar() { int x = 2; };

#define _GNU_SOURCE
#include <sys/mman.h>
void foo() {
  size_t a = 4096;
  mremap;
}

Dredd will mutate the statement in bar() and place its headers and prelude functions at the beginning of file.

Not that I encountered this problem in an actual codebase (and I believe this pattern is very unlikely), but I just opened an issue here for documentation purposes.

@afd
Copy link
Member

afd commented Aug 30, 2024

As the problem of where to insert the prelude seems hard to solve in general, one option could be to allow the user to write a dummy function prototype:

void __dredd_prelude();

in a source file.

If encountered, the Dredd prelude would be inserted right after (or in place of) this function prototype. Otherwise, the current behaviour would be used.

This would allow the user to control where the prelude is emitted in tricky cases.

@afd
Copy link
Member

afd commented Sep 4, 2024

Actually this is especially difficult, because of the fact that Dredd would mutate the code in bar, for which it would need its header files.

@afd
Copy link
Member

afd commented Sep 18, 2024

I propose we close this as __dredd_prelude_start() offers one way to control where the prelude is placed, and the troubleshooting part of the README explains that placement of the prelude can be an issue. I don't see a way to solve this problem in full generality, meaning that this issue would just remain open indefinitely.

@afd afd closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants