2018-02-17 23:33:37 +00:00
|
|
|
# DEVELOPERS
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
This file aims to describe an introduction for developers to work
|
|
|
|
on the code base of radare2 project.
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Code style
|
|
|
|
|
2011-07-01 11:22:13 +00:00
|
|
|
In order to contribute with patches or plugins we encourage you to
|
|
|
|
use the same coding style as the rest of the code base.
|
|
|
|
|
2016-03-05 23:07:28 +00:00
|
|
|
You may find some notes on this topic [here](https://github.com/radare/radare2/blob/master/CONTRIBUTING.md#coding-style-guidelines)
|
2015-11-12 15:55:43 +00:00
|
|
|
and doc/vim.
|
2011-07-01 11:22:13 +00:00
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
### Editor configuration
|
|
|
|
|
|
|
|
Vim/Neovim:
|
|
|
|
|
|
|
|
```vim
|
|
|
|
setl cindent
|
|
|
|
setl tabstop=4
|
|
|
|
setl noexpandtab
|
|
|
|
setl cino=:0,+0,(2,J0,{1,}0,>4,)1,m2
|
|
|
|
```
|
|
|
|
|
|
|
|
Emacs:
|
|
|
|
|
|
|
|
```elisp
|
|
|
|
(c-add-style "radare2"
|
|
|
|
'((c-basic-offset . 4)
|
|
|
|
(tab-width . 4)
|
|
|
|
(indent-tabs-mode . t)
|
|
|
|
;;;; You would need (put 'c-auto-align-backslashes 'safe-local-variable 'booleanp) to enable this
|
|
|
|
;; (c-auto-align-backslashes . nil)
|
|
|
|
(c-offsets-alist
|
|
|
|
(arglist-intro . ++)
|
|
|
|
(arglist-cont . ++)
|
|
|
|
(arglist-cont-nonempty . ++)
|
|
|
|
(statement-cont . ++)
|
|
|
|
)))
|
|
|
|
```
|
|
|
|
|
|
|
|
You may use directory-local variables by putting
|
|
|
|
```elisp
|
|
|
|
((c-mode . ((c-file-style . "radare2"))))
|
|
|
|
```
|
|
|
|
|
|
|
|
into `.dir-locals.el`.
|
|
|
|
|
|
|
|
## Modules
|
|
|
|
|
2011-07-01 11:22:13 +00:00
|
|
|
The radare2 code base is modularized into different libraries that are
|
|
|
|
found in libr/ directory. The binr/ directory contains the programs
|
|
|
|
that use the libraries.
|
|
|
|
|
|
|
|
It is possible to generate PIC/nonPIC builds of the libraries and also
|
|
|
|
to create a single static library, so you can use a single library
|
|
|
|
archive (.a) to link your programs and get your programs using radare
|
2015-01-29 18:56:59 +00:00
|
|
|
framework libraries without depending on them. See doc/static for more info.
|
2011-07-01 11:22:13 +00:00
|
|
|
|
2014-06-19 11:32:10 +00:00
|
|
|
The following presentation gives a good overview of the libraries:
|
|
|
|
|
|
|
|
http://radare.org/get/lacon-radare-2009/
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## API
|
|
|
|
|
2014-06-19 11:32:10 +00:00
|
|
|
As mentioned in README.md, the API itself is maintained in a different
|
|
|
|
repository. The API function definitions in C header files are derived
|
|
|
|
from and documented in the radare2-bindings repository, found at:
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
2014-06-19 11:32:10 +00:00
|
|
|
git clone git://github.com/radare/radare2-bindings
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2014-06-19 11:32:10 +00:00
|
|
|
|
|
|
|
Currently the process of updating the header files from changed API
|
|
|
|
bindings requires human intervention, to ensure that proper review
|
|
|
|
occurs. Incorrect definitions in the C header files will trigger
|
|
|
|
a build failure in the bindings repository.
|
|
|
|
|
|
|
|
If you are able to write a plugin for various IDE that can associate
|
|
|
|
the bindings with the header files, such a contribution would be
|
|
|
|
very welcome.
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Dependencies
|
|
|
|
|
2014-05-18 02:50:44 +00:00
|
|
|
radare2 can be built without any special dependency. It just requires
|
2011-07-01 11:22:13 +00:00
|
|
|
a C compiler, a GNU make and a unix-like system.
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Cross compilation
|
|
|
|
|
2015-11-12 15:55:43 +00:00
|
|
|
The instructions to crosscompile r2 to Windows are in doc/windows.
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
You may find other documents in doc/ explaining how to build it on iOS,
|
|
|
|
linux-arm and others, but the procedure is like this:
|
|
|
|
|
2015-11-12 15:55:43 +00:00
|
|
|
- define `CC`
|
|
|
|
- use a different compiler profile with `--with-compiler`
|
|
|
|
- use a different OS with `--with-ostype`
|
|
|
|
- type `make`
|
|
|
|
- install in `DESTDIR`
|
2011-07-01 11:22:13 +00:00
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Source repository
|
|
|
|
|
2014-05-18 02:50:44 +00:00
|
|
|
The source of radare2 can be found in the following github repository.
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
2012-12-12 18:27:25 +00:00
|
|
|
git clone git://github.com/radare/radare2
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2014-05-18 02:50:44 +00:00
|
|
|
Other packages radare2 depends on, such as Capstone, are pull from
|
|
|
|
their git repository as required.
|
|
|
|
|
2011-07-01 11:22:13 +00:00
|
|
|
To get an up to date copy of the repository you should perform the
|
|
|
|
following steps:
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
2012-12-12 18:27:25 +00:00
|
|
|
git pull
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
If you have conflicts in your local copy it's because you have modified
|
2014-05-18 02:50:44 +00:00
|
|
|
files which are conflicting with the incoming patchsets. To get a clean
|
2011-07-01 11:22:13 +00:00
|
|
|
source directory type the following command:
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
2012-12-12 18:27:25 +00:00
|
|
|
git clean -xdf
|
|
|
|
git reset --hard
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2018-02-17 23:33:37 +00:00
|
|
|
|
|
|
|
## Compilation
|
|
|
|
|
2011-07-01 11:22:13 +00:00
|
|
|
Inter-module rebuild dependencies are not handled automatically and
|
|
|
|
require human interaction to recompile the affected modules.
|
|
|
|
|
|
|
|
This is a common issue and can end up having outdated libraries trying
|
|
|
|
to use deprecated structures which may result into segfaults.
|
|
|
|
|
|
|
|
You have to make clean on the affected modules or just, if you are not
|
2014-05-18 02:50:44 +00:00
|
|
|
sure enough that everything is ok just make clean the whole project.
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
If you want to accelerate the build process after full make cleans
|
|
|
|
you should use ccache in this way:
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2011-07-01 11:22:13 +00:00
|
|
|
export CC="ccache gcc"
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2011-07-01 11:22:13 +00:00
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Installation
|
|
|
|
|
2011-07-01 11:22:13 +00:00
|
|
|
Developers use to modify the code, type make and then try.
|
|
|
|
|
|
|
|
radare2 have a specific makefile target that allows you to install
|
|
|
|
system wide but using symlinks instead of hard copies.
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
2018-02-17 23:33:37 +00:00
|
|
|
sudo make symstall
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2011-07-01 11:22:13 +00:00
|
|
|
This kind of installation is really helpful if you do lot of changes
|
|
|
|
in the code for various reasons.
|
|
|
|
|
|
|
|
- only one install is required across multiple builds
|
|
|
|
- installation time is much faster
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Regression testing
|
2014-05-18 02:50:44 +00:00
|
|
|
|
|
|
|
The source of the radare2 regression test suite can be found in the
|
|
|
|
following github repository.
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
2014-05-18 02:50:44 +00:00
|
|
|
git clone git://github.com/radare/radare2-regressions
|
2015-11-12 15:55:43 +00:00
|
|
|
```
|
2014-05-18 02:50:44 +00:00
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
See the `README.md` file in that repository for further information.
|
2014-05-18 02:50:44 +00:00
|
|
|
|
2014-06-19 11:32:10 +00:00
|
|
|
The existing test coverage can always do with improvement, so if you can
|
|
|
|
contribute additions tests that would be gratefully accepted.
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Reporting bugs
|
|
|
|
|
2014-05-18 02:50:44 +00:00
|
|
|
If you notice any misfeature, issue, error, problem or you just
|
|
|
|
don't know how to do something which is supposed to be covered
|
2011-07-01 11:22:13 +00:00
|
|
|
by this framework.
|
|
|
|
|
2015-02-07 00:41:54 +00:00
|
|
|
You should report it into the github issues page.
|
|
|
|
https://github.com/radare/radare2/issues
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
Otherwise, if you are looking for some more feedback I will
|
|
|
|
encourage you to send an email to any of the emails enumerated
|
|
|
|
in the AUTHORS file.
|
|
|
|
|
|
|
|
Anyway, if you want to get even more feedback and discuss this
|
2015-11-12 15:55:43 +00:00
|
|
|
in a public place: join the #radare channel on irc.freenode.net.
|
2011-07-01 11:22:13 +00:00
|
|
|
|
2015-02-07 00:41:54 +00:00
|
|
|
The issues page of Github contains a list of all the bugs that
|
|
|
|
have been reported classified with labels by difficulty, type,
|
|
|
|
milestone, etc. it is a good place to start if you are looking
|
|
|
|
to contribute.
|
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## Contributing with patches
|
|
|
|
|
2012-12-12 18:27:25 +00:00
|
|
|
All the development happens in the git repository. It is
|
2015-11-12 15:55:43 +00:00
|
|
|
good that all patches can be applied against the `git HEAD`.
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
I can get patches in unidiff format like this:
|
2015-11-12 15:55:43 +00:00
|
|
|
```sh
|
|
|
|
git diff > p
|
|
|
|
```
|
2011-07-01 11:22:13 +00:00
|
|
|
|
2018-02-17 23:33:37 +00:00
|
|
|
## HOW TO RELEASE
|
2011-07-19 10:52:51 +00:00
|
|
|
|
2015-11-12 15:55:43 +00:00
|
|
|
- Set `RELEASE=1` in global.mk and r2-bindings/config.mk.acr.
|
|
|
|
- Use `bsdtar` from libarchive package. GNU tar is broken.
|
2011-07-19 10:52:51 +00:00
|
|
|
|
2015-11-12 15:55:43 +00:00
|
|
|
RADARE2
|
|
|
|
---
|
2011-07-19 10:52:51 +00:00
|
|
|
- bump revision
|
2015-11-12 15:55:43 +00:00
|
|
|
- `./configure`
|
|
|
|
- `make dist`
|
|
|
|
|
|
|
|
R2-BINDINGS
|
|
|
|
---
|
|
|
|
- `./configure --enable-devel`
|
|
|
|
- `make`
|
|
|
|
- `make dist`
|
2011-07-01 11:22:13 +00:00
|
|
|
|
|
|
|
--pancake
|