binutils

How to link a gas assembly program that uses the C standard library with ld without using gcc?

自作多情 提交于 2019-11-28 16:52:39
问题 As an exercise to learn more precisely how c programs work and what minimum level of content must exist for a program to be able to use libc, I've taken it upon myself to attempt to program primarily in x86 assembly using gas and ld. As a fun little challenge, I've successfully assembled and linked several programs linked to different self-made dynamic libraries, but I have failed to be able to code a program from scratch to use libc function calls without directly using gcc. I understand the

Recipe for compiling binutils & gcc together?

空扰寡人 提交于 2019-11-28 16:01:07
According the the gcc build instructions you can build binutils concurrently with building gcc (as well as gmp,mpc,etc). Here's what that page says : If you also intend to build binutils (either to upgrade an existing installation or for use in place of the corresponding tools of your OS), unpack the binutils distribution either in the same directory or a separate one. In the latter case, add symbolic links to any components of the binutils you intend to build alongside the compiler (bfd, binutils, gas, gprof, ld, opcodes, ...) to the directory containing the GCC sources. Likewise the GMP,

How to list library dependencies of a non-native binary?

﹥>﹥吖頭↗ 提交于 2019-11-28 15:57:43
When developing for native platform, I can use ldd to list all the shared libraries (.so files) a binary executable I build will try to load upon start-up. But when cross-compiling, I don't know how to get the same information. The ldd is not a normal binutils utility, like strip or ar , that can be built alongside gcc for cross compiling, but instead, it is a cryptic shell script that apparently can only run on native platform. So, using the cross-target binutils tools, is there any way to get a list of the dynamically linked dependency for of a foreign binary? is there any way to get a list

Weird MIPS assembler behavior with jump (and link) instruction

给你一囗甜甜゛ 提交于 2019-11-28 12:16:22
So, we're studying MIPS architecture at school and we're implementing a MIPS32 architecture. I thought I'd use GNU cross-binutils as assembler but I'm getting weird output when dealing with instructions jal, j and jr. The assembler seems to insert the instructions at the wrong places. I have no idea why this happens, and I doubt the MIPS assembler would be that broken, so I assume this is supposed to happen. Here is my dummy assembly file: .section .text .globl __start __start: addi $a0, $0, 100 addi $a1, $0, 200 jal test test: add $v0, $a0, $a1 jr $ra However, when I disassemble I get this

How to get instruction information from libopcodes?

戏子无情 提交于 2019-11-28 09:12:20
I am writing a tool which uses libbfd and libopcodes in x86-32 and x86-64 Linux to perform disassembly. The problem is that whilst I am able to get libopcodes to disassemble, I am unable to get any instruction information. For the purposes of demonstration, I have made a minimal example which reproduces my issue. The program should disassemble itself from entry point to the first RET / RETQ . The code is a bit hacked up with globals and error checking has been omitted for brevity, etc. but should illustrate the issue clearly. #include <bfd.h> #include <dis-asm.h> #include <stdbool.h> #include

An objcopy equivalent for Mac / iPhone?

a 夏天 提交于 2019-11-27 23:04:10
问题 I would like to rename symbols inside object files (.o) with something that would be the Mac equivalent of binutils' objcopy --redefine-syms tool. I found no arm-apple-darwin10-objcopy . I tried the MacPorts' arm-elf-binutils port and also tried to play a bit with otool and segedit without much success. Any ideas please? 回答1: Sounds like a job for Agner Fog's objconv. From the announcement: I have now finished making full support for Mach-O files in the object file converter mentioned in my

Recipe for compiling binutils & gcc together?

主宰稳场 提交于 2019-11-27 09:29:59
问题 According the the gcc build instructions you can build binutils concurrently with building gcc (as well as gmp,mpc,etc). Here's what that page says : If you also intend to build binutils (either to upgrade an existing installation or for use in place of the corresponding tools of your OS), unpack the binutils distribution either in the same directory or a separate one. In the latter case, add symbolic links to any components of the binutils you intend to build alongside the compiler (bfd,

How to list library dependencies of a non-native binary?

青春壹個敷衍的年華 提交于 2019-11-27 09:28:27
问题 When developing for native platform, I can use ldd to list all the shared libraries (.so files) a binary executable I build will try to load upon start-up. But when cross-compiling, I don't know how to get the same information. The ldd is not a normal binutils utility, like strip or ar , that can be built alongside gcc for cross compiling, but instead, it is a cryptic shell script that apparently can only run on native platform. So, using the cross-target binutils tools, is there any way to

How to install gnu ld on mac os x 10.6?

可紊 提交于 2019-11-27 09:06:09
I'm having a lot of trouble compiling the otherwise excellent Contiki OS on my macbook pro (with mac os x 10.6). Contiki actually uses a lot of GNU-specific features and options of GCC, AR, LD, and so on. So I installed those utilities via macports, but it looks like "port install binutils" does not install GNU ld, does it ? So, the question is, how do I get GNU ld on my mac ? Is there a simple alternative to the hard-way (i.e. the wget, configure, make, make install way) ? As far as I can tell, GNU binutils does not support the Mach-O format. None of the documentation mentions it, and some

Is accessing the “value” of a linker script variable undefined behavior in C?

一个人想着一个人 提交于 2019-11-27 07:33:35
问题 The GNU ld (linker script) manual Section 3.5.5 Source Code Reference has some really important information on how to access linker script "variables" (which are actually just integer addresses) in C source code. I used this info. to extensively use linker script variables, and I wrote this answer here: How to get value of variable defined in ld linker script from C. However, it is easy to do it wrong and make the mistake of trying to access a linker script variable's value (mistakenly)