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

Kumarak/embed compile command #43489

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Conversation

pgoodman
Copy link
Member

No description provided.

@pgoodman pgoodman requested a review from woodruffw as a code owner June 28, 2023 23:30
src/blight/actions/embed_commands.py Outdated Show resolved Hide resolved
src/blight/actions/embed_commands.py Outdated Show resolved Hide resolved
Comment on lines 105 to 108
variable = """
#ifndef __linux__
__attribute__((section(\"__DATA,.trailofbits_cc\")))
#else
__attribute__((section(\".trailofbits_cc, \\"S\\", @note;\\n#\")))
#endif
__attribute__((used))
static const char cc_{}[] = \"{}\";
""".format(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Turn this into a module-level template string, and then do something like:

_VARIABLE_TEMPLATE.format(cmd_hash, cc_string)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kumarak can you address this, and also make it:

#ifndef __linux__
__attribute__((section(\"__DATA,.trailofbits_cc\")))
#elifdef __clang__
__attribute__((section(\".trailofbits_cc\")))
#else
__attribute__((section(\".trailofbits_cc, \\"S\\", @note;\\n#\")))
#endif



class EmbedCommands(CompilerAction):
def __init__(self, config):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def __init__(self, config):
def __init__(self, config: dict[str, str]) -> None:

src/blight/actions/embed_commands.py Outdated Show resolved Hide resolved
def __init__(self, config):
super().__init__(config)

def _get_header_file(self, cmd_hash: str):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def _get_header_file(self, cmd_hash: str):
def _get_header_file(self, cmd_hash: str) -> str:

os.remove(header_file)
return header_file

def before_run(self, tool: Tool) -> None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
def before_run(self, tool: Tool) -> None:
def before_run(self, tool: CompilerTool) -> None:

kumarak and others added 4 commits November 16, 2023 12:07
update weak symbol attribute

Update record compiler action

fix comments and compiler path
Bug fix

Bug fix

Use dictionary syntax

Use the Tool properties directly instead of going through the dictionary.

Remove leading single quotes. Not sure how those got there. There is still some kind of issue, though.

More entropy to include file names

Tool.env is not a thing.

Go back to old way of checking for .S files.
Signed-off-by: William Woodruff <[email protected]>

fix review comments
@kumarak kumarak force-pushed the kumarak/embed_compile_command branch from 1b11bc9 to 40daf19 Compare November 16, 2023 17:53
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

Successfully merging this pull request may close these issues.

3 participants