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

Assignment of a generic8_t * to generic64_t #13

Open
yangzao opened this issue Apr 19, 2024 · 2 comments
Open

Assignment of a generic8_t * to generic64_t #13

yangzao opened this issue Apr 19, 2024 · 2 comments
Assignees
Labels

Comments

@yangzao
Copy link

yangzao commented Apr 19, 2024

Original code:

char *str_l = "local string";
char *str_l_alt = "another local string";
....
str_l = str_l_alt;

Decompiled code:

generic8_t *_offset_16;
_stack._offset_16 = "another local string";
...
generic64_t _var_1;
...
_var_1 = _stack._offset_16;

Description:
_stack._offset_16 is declared as a pointer and is assigned to a generic64_t _var_1 (I assume it's int64_t).

Files:
3.zip
(original code orig.c, original exec orig_exec, PTML file dec.ptml, and decompiled code dec_default.c are included)
Reproduce the issue:

  1. compiled orig.c with CLANG and -O0.
  2. decompile the program with rev.ng into C code.
  3. this issue is in func_1() near the end of decompiled code, within the default case.
@aleclearmind aleclearmind changed the title pointer assigning to generic64_t Assignment of a generic8_t * to generic64_t Apr 29, 2024
@aleclearmind
Copy link
Contributor

Moving to revng-c, assigning to @pfez.

The generated code emits a warning, but it's a known thing.
From share/revng-c/compile-flags.cfg:

# The following two are caused by the fact that we don't handle very cleanly
# integer casts and pointer casts yet.
# In principle we should be able to remove these when we handle casts properly,
# but at the same time if we end up using implicit casts and conversions for
# improving conciseness of decompiled code these may be impossible to ever
# disable because they would warn against the implicit casts that we're
# exploiting for concisensess.
-Wno-int-conversion
-Wno-int-to-pointer-cast

@pfez might have something to add about future directions, but, as of now, we consider this not a bug, since the warning is not in the list we're interested in.

@aleclearmind aleclearmind transferred this issue from revng/revng Apr 29, 2024
@pfez pfez added the low-prio label May 2, 2024
@pfez
Copy link
Contributor

pfez commented May 2, 2024

I agree with @aleclearmind , we don't consider this to be a bug at the moment.

We have an ongoing effort, that should be merged not too far in the future, to improve the situation of implicit vs explicit casts in the decompiled C code. I'll leave this issue open for now to try and revisit it after we complete the work on casts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants