darwin-on-arm / xnu

Porting the Darwin kernel to the AArch64/ARMv7/ARMv6-A architectures.
Other
583 stars 145 forks source link

[Debian] Compiler bug: genassym.c -> assym.S #38

Open wargio opened 8 years ago

wargio commented 8 years ago

I have a this problem on debian: when i compile the assym.S is totally empty. looks like the compiler removes the macro when it expands it. file: https://github.com/darwin-on-arm/xnu/blob/master/osfmk/arm/genassym.c#L111

#define DECLARE(SYM,VAL) \
    __asm("#DEFINITION##define " SYM "\t%0" : : "n" ((u_int)(VAL)))
#endif

i fixed it in this way: on that file it becomes:

#define DECLARE(SYM,VAL) \
    __asm(".file \"#DEFINITION##define " SYM "       %0####\"" : : "n" ((u_int)(VAL)))
#endif

and i changed the makefile template: File: https://github.com/darwin-on-arm/xnu/blob/master/osfmk/conf/Makefile.template#L123

$(_v)sed -e '/#DEFINITION#/!d' -e 's/^.*#DEFINITION#//' -e 's/\$$//' -e 'p' -e 's/#//2' -e 's/[^A-Za-z0-9_]*\([A-Za-z0-9_]*\)/ \1_NUM/2' genassym.o > ${@}

to

$(_v)sed -e '/.file\s*\"#DEFINITION#/!d' -e 's/^.*#DEFINITION#//' -e 's/####\"//' -e 's/\$$//' -e 'p' -e 's/#//2' -e 's/[^A-Za-z0-9_]*\([A-Za-z0-9_]*\)/ \1_NUM/2' genassym.o > ${@}

Anybody knows a better why to fix this?

nightsuns commented 8 years ago

below is my fix:


osfmk/arm/genassym.c | 7 +++++-- osfmk/conf/Makefile.template | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/osfmk/arm/genassym.c b/osfmk/arm/genassym.c index 9b3d063..d3f46d9 100644 --- a/osfmk/arm/genassym.c +++ b/osfmk/arm/genassym.c @@ -108,8 +108,11 @@

define DECLARE(SYM,VAL) \

__asm("#DEFINITION#\t.set\t" SYM ",\t%0" : : "n" ((u_int)(VAL)))

else

+//#define DECLARE(SYM,VAL) \ +// __asm("#DEFINITION##define " SYM "\t%0" : : "n" ((u_int)(VAL)))

define DECLARE(SYM,VAL) \

2.7.4

spotlightishere commented 8 years ago

@nightsuns, can you please post the patch in a code block so I can copy/paste it? GitHub's markdown took over it 😃

johnothwolo commented 7 years ago

Hey @nightsuns, please paste a readable patch.

spotlightishere commented 7 years ago

I'm glad I got a notification from this issue. I was working with the GitHub API at the time and had the idea of just getting the raw message. I don't know how to escape backticks on Github and this patch appears to have some... so, I'll just show you how to get the raw answer.

curl -i "https://api.github.com/repos/darwin-on-arm/xnu/issues/38/comments"

It'd be under the body element in the JSON response. You'll have to replace \n with actual newlines.

wargio commented 7 years ago

https://github.com/wargio/xnu/commit/b17d2a5f396161467a3f9f719b76721ad6a2474b.patch

wargio commented 7 years ago

that's my patch

johnothwolo commented 7 years ago

Oh thanks @wargio, do you think it would be possible to emulate ios with this kernel?

johnothwolo commented 7 years ago

Somehow the kernel is still not building, I followed the instructions and the patch didn't work. The assym.s file is empty in the Build folder. I'm kinda new at this stuff....

wargio commented 7 years ago

try with my fork.

johnothwolo commented 7 years ago

It failed with the same error. I'm on macOS 10.12.6. I know enough c and I understand what the makefile template was trying to do, but i'm not fluent with unix commands. I checked the build without the patch:

sed -e '/#DEFINITION#/!d' -e 's/^.*#DEFINITION#//' -e 's/\$$//' -e 'p' -e 's/#//2' -e 's/[^A-Za-z0-9_]*\([A-Za-z0-9_]*\)/ \1_NUM/2' genassym.o >${@}

And got some definitions which were incomplete or something, but when i tried with the patch:

sed -e '/.file\s*\"#DEFINITION#/!d' -e 's/^.*#DEFINITION#//' -e 's/####\"//' -e 's/\$$//' -e 'p' -e 's/#//2' -e 's/[^A-Za-z0-9_]*\([A-Za-z0-9_]*\)/ \1_NUM/2' genassym.o > ${@}

assym.S ended up empty.