radareorg / radare2

UNIX-like reverse engineering framework and command-line toolset
https://www.radare.org/
GNU Lesser General Public License v3.0
20.34k stars 2.97k forks source link

Build error OS: FreeBSD 9.x,10.x/gcc v4.2.1 AT: libr/anal/p/anal_avr.c ERR: unknown field 'consts' at 'cpu_models[]' #6268

Closed unixfreaxjp closed 7 years ago

unixfreaxjp commented 7 years ago

This is the copy of wrongly posted issue at https://github.com/radare/radare/issues/3#

The usage of (undeclared/undefined) .consts for FreeBSD is not compatible in /libr/anal/p/anal_avr.c this function at CPU_MODEL cpu_models[], xref: (1) https://github.com/radare/radare2/blob/master/libr/anal/p/anal_avr.c#L112 and (2) https://github.com/radare/radare2/blob/master/libr/anal/p/anal_avr.c#L120 problem: **Anonymized Union** Code:

CPU_MODEL cpu_models[] = {
    {
        .model = "ATmega8", .pc = 13,
        .consts = {  // <=====================
            cpu_reg_common,
            cpu_memsize_common,
            cpu_pagesize_32,
            NULL
        }
    },
    { .model = "ATmega640",   .pc = 15,
        .consts = { // <=====================
            cpu_reg_common,
            cpu_memsize_m640_m1280m_m1281_m2560_m2561,
            cpu_pagesize_256,
            NULL
        },
    },
    { .model = "ATmega1280",  .pc = 16, .inherit = "ATmega640" },
    { .model = "ATmega1281",  .pc = 16, .inherit = "ATmega640" },
    { .model = "ATmega2560",  .pc = 17, .inherit = "ATmega640" },
    { .model = "ATmega2561",  .pc = 17, .inherit = "ATmega640" },
    { .model = "ATmega88",    .pc = 8,  .inherit = "ATmega8" },
    { .model = "unknown_avr", .pc = 8,  .inherit = "ATmega8" } // default AVR - ATmega8 forever!
//  CPU_MODEL_DECL ("ATmega168",   13, 512, 512),
};

@radare @XVilka @crowell @jvoisin @maijin

radare commented 7 years ago

wat? build fine here

unixfreaxjp commented 7 years ago

Maijin commented 5 minutes ago @unixfreaxjp next time please open issue on https://github.com/radare/radare2 repo not "radare"

Done.

@radare commented 7 minutes ago cant reproduce

It was occured in x32/gcc 4.2.1 20070831 patched [FreeBSD] Let's see if this occured in x86-64 & amd64 FreeeBSD too (hold on..)

radare commented 7 years ago

i have tested on freebsd-amd64, linux-arm and osx-x86-64, no issues at all

XVilka commented 7 years ago

What compiler do you use?

unixfreaxjp commented 7 years ago

@XVilka commented 2 minutes ago What compiler do you use?

$ gcc --version

gcc (GCC) 4.2.1 20070831 patched [FreeBSD]
Copyright (C) 2007 Free Software Foundation, Inc.
XVilka commented 7 years ago

It's this bug https://gcc.gnu.org/bugzilla/show_bug.cgi?id=10676

XVilka commented 7 years ago

@unixfreaxjp please try now

unixfreaxjp commented 7 years ago

@radare commented 14 minutes ago i have tested on freebsd-amd64, linux-arm and osx-x86-64, no issues at all

This, occurred as well in amd64 in two machines different FreeBSD version (9.x and 10.x) One quick grabbed error log: https://github.com/unixfreaxjp/dev/blob/master/r2freebsdx64-4.md

Maijin commented 7 years ago

@unixfreaxjp please try now

unixfreaxjp commented 7 years ago

@XVilka commented 2 minutes ago @unixfreaxjp please try now

Retrying now. @Maijin

XVilka commented 7 years ago

The solution is to eliminate anonymous union.

unixfreaxjp commented 7 years ago

@XVilka @Maijin @radare build error is persisted. In union initial part. It was well before in last week compilation.. same cc (GCC) 4.2.1 20070831 patched [FreeBSD] This is gcc compatibility problem..

x32 log:

Tue Nov 29 20:33:56 JST 2016
heads/master-0-g74bb05a
 :
CC anal_avr.c
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:112: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:112: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: error: field name not in record or union initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: error: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:113: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:114: warning: initialization from incompatible pointer type
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:115: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:115: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:116: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:116: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:118: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:118: warning: (near initialization for 'cpu_models[0].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:122: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:122: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: error: field name not in record or union initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: error: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: warning: braces around scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:123: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:124: warning: initialization from incompatible pointer type
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:125: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:125: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:126: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:126: warning: (near initialization for 'cpu_models[1].inherit')
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:128: warning: excess elements in scalar initializer
/TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.c:128: warning: (near initialization for 'cpu_models[1].inherit')
gmake[3]: *** [/TEST/radare/radare2/libr/../global.mk:42: /TEST/radare/radare2/libr/..//libr/anal/p/anal_avr.o] Error 1
gmake[3]: *** Waiting for unfinished jobs....
gmake[2]: *** [Makefile:83: anal] Error 2
gmake[2]: *** Waiting for unfinished jobs....
/TEST/radare/radare2/libr/bin/p
SHLR=/TEST/radare/radare2/libr/..//libr/../shlr
gmake[1]: *** [Makefile:31: all] Error 2
gmake: *** [Makefile:51: all] Error 2
unixfreaxjp commented 7 years ago

@XVilka @Maijin @radare

all of our dev systems is using gcc 4.2.1, what should I do to make this work?

XVilka commented 7 years ago

Someone will do the fix today, just not right now.

unixfreaxjp commented 7 years ago

I will urgently plan upgrade gcc on many of the bsd analysis clusters then. We use servers to analyze UNIX bad stuff, not client.. upgrading gcc will upgrade ton of dev stuff too.. Taking off the urgent flag. Will re-open the issue if still persist after using recent gcc. Thank's for the answers, appreciated. If any solution for this, please help. One urgent analysis is in progress now, will use version RELEASE-0.10.5(PRECON) for quick workup, built well:

radare2 0.10.5 9999999 @ freebsd-x86-32 git.0.10.5
commit: HEAD build: 2016-11-29

Cheers.

unixfreaxjp commented 7 years ago

@radare @XVilka @Maijin @unixfreaxjp @killabytenow I still wonder since when gcc 4.2.1. is becoming incompatible, since I swear it was working few weeks back. Below is the report I run on several radare2 built for test under gcc 4.2.1 :

radare2-1.0 aka "Finally" works, proof:

$ date&&r2 -v
Thu Dec  1 14:37:04 JST 2016
radare2 1.0 9999999 @ freebsd-x86-32 git.1.0
commit: HEAD build: 2016-12-01

radare2 version 1.0.2 is also proven works / built fine:

$ date&&r2 -v
Thu Dec  1 14:44:38 JST 2016
radare2 1.0.2 9999999 @ freebsd-x86-32 git.1.0.2
commit: HEAD build: 2016-12-01

##The problem is sourced in here:##

There must be a code change in development after 1.0.2 RELEASE (November the 10th, 2016) that affects this good gcc compatibility quality that radare2 had before, I was just tracing it now, to find this commit code (on Nov 19, 2016 ), the code is here: https://github.com/radare/radare2/commit/9d6bbf99c81f7788a5d8333dc205ed5fe87ad055 by @killabytenow is the source.

A policy in the development need to be decided on the anonymous union usage on the radare2 code. I leave this matter to the development tops to decide.

radare commented 7 years ago

yeah im not really a fan of anonymous unions, wondering if there's any gcc flag to enforce this

radare commented 7 years ago

why this issue is closed if its not fixed?

unixfreaxjp commented 7 years ago

why this issue is closed if its not fixed?

Because I know that you are busy.. and people can use workaround to use 1.0.2,

wondering if there's any bcc flag to enforce this

Believe me, I already on seeking that too. But there is no easy configure option that can be used for forcing this.

I agree for the @XVilka suggestion for the recoding without anonymous unions , or, we are accepting the limitation on used gcc version. It is the decision that you should make due to product's compatibility, quality, roadmaps are related.

unixfreaxjp commented 7 years ago

I tested https://github.com/radare/radare2/commit/13c15cb0a2593a6cc5c9d12a0c847e033a7cf16e (and to de-anonymize the AVR union ) on x86-32 and x86-64

32bit:

$ date&&r2 -v&&uname
Thu Dec  1 23:21:57 JST 2016
radare2 1.1.0-git 13133 @ freebsd-x86-32 git.1.0.2-189-ge4b5f0f
commit: e4b5f0f32b0f6bff4f3537bd2800d5801eb5e513 build: 2016-12-01
FreeBSD

64bit:

$ pwd&&date&&r2 -v&&uname
/TEST/radare2
Thu Dec  1 23:29:40 JST 2016
radare2 1.1.0-git 13133 @ freebsd-x86-64 git.1.0.2-189-ge4b5f0f
commit: e4b5f0f32b0f6bff4f3537bd2800d5801eb5e513 build: 2016-12-01
FreeBSD

Thank you now it works just fine :)

radare commented 7 years ago

You are welcome

On 1 Dec 2016, at 15:30, unixfreaxjp notifications@github.com wrote:

I tested 13c15cb (Deanonymize the AVR union ) on x86-32 and x86-64

32bit:

$ date&&r2 -v&&uname Thu Dec 1 23:21:57 JST 2016 radare2 1.1.0-git 13133 @ freebsd-x86-32 git.1.0.2-189-ge4b5f0f commit: e4b5f0f32b0f6bff4f3537bd2800d5801eb5e513 build: 2016-12-01 FreeBSD 64bit:

$ pwd&&date&&r2 -v&&uname /TEST/radare2 Thu Dec 1 23:29:40 JST 2016 radare2 1.1.0-git 13133 @ freebsd-x86-64 git.1.0.2-189-ge4b5f0f commit: e4b5f0f32b0f6bff4f3537bd2800d5801eb5e513 build: 2016-12-01 FreeBSD Thank you very much @radare, it works just fine :)

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.