avr-gcc

Does gnu ld link in whole object files or only the needed functions?

十年热恋 提交于 2019-12-10 09:26:11
问题 We have a library and an executable, that is to be statically linked to the lib. We want to minimize the program space of the final executable. According to avr-libc's documentation: the linker links in THE ENTIRE OBJECT MODULE in which the function is located On the other hand, my colleagues are unanimous on the point that at some pass, the linker throws away any unused functions. So who is correct or am I misunderstanding something? Is the answer consistent throughout gcc or are we talking

Undefined reference to 'operator delete(void*)'

a 夏天 提交于 2019-12-09 08:21:35
问题 I'm new to C++ programming, but have been working in C and Java for a long time. I'm trying to do an interface-like hierarchy in some serial protocol I'm working on, and keep getting the error: Undefined reference to 'operator delete(void*)' The (simplified) code follows below: PacketWriter.h: class PacketWriter { public: virtual ~PacketWriter() {} virtual uint8_t nextByte() = 0; } StringWriter.h: class StringWriter : public PacketWriter { public: StringWriter(const char* message); virtual

Extern variable only in header unexpectedly working, why?

自作多情 提交于 2019-12-08 19:31:48
问题 I'm currently updating a C++ library for Arduino (Specifically 8-bit AVR processors compiled using avr-gcc). Typically the authors of the default Arduino libraries like to include an extern variable for the class inside the header, which is defined in the class .cpp file also. This I assume is basically to have everything provided ready to go for newbies as built-in objects. The scenario I have is: The library I have updated no longer requires the .cpp file and I have removed it from the

Can GNU ld be instructed to print which .o files are needed during a link?

て烟熏妆下的殇ゞ 提交于 2019-12-08 09:31:37
问题 A little background: I'm trying to build an AVR binary for an embedded sensor system, and I'm running close to my size limit. I use a few external libraries to help me, but they are rather large when compiled into one object per library. I want to pull these into smaller objects so only the functionality I need is linked into my program. I've already managed to drop the binary size by 2k by splitting up a large library. It would help a lot to know which objects are being used at each stage of

Avr asm label*2

青春壹個敷衍的年華 提交于 2019-12-06 16:00:02
Hi i am new in avr asm programming,in the example below, i have few questions: 1) Is it label: 8 bit or 16bit long? 2) Why multiplication label with 2 is needed? 3) Instruction LPM is placing their result in register R0? If so, what does that have to do with Z? 4) Can you explaine the quoted text from the provided link: "If the address is not multiplied by two and label is at byte address 0x60 (word address 0x30), Z will point at the code stored there. I hope this clarified the addressing problem. Other versions are" ldi ZL, low(2*label) ldi ZH, high(2*label) label: .db "Hello world", 0 lpm

AVR-GCC: Error: garbage at end of line

北慕城南 提交于 2019-12-06 09:03:47
问题 I have problem with stack init lines because avr-gcc returns LED_Blink.asm:10: Error: garbage at end of line On lines: ldi r17, low(RAMEND) ldi r17, high(RAMEND) And I am confused. I have already defined RAMEND. I used avr-gcc with this command: avr-gcc -x assembler -mmcu=atmega328p LED_Blink.asm My assembly code: .equ SPL, 0x3d .equ SPH, 0x3e .equ RAMEND, 0x8ff .equ PORTB, 0x05 .equ DDRB, 0x04 .org 0x000000 rjmp main main: ldi r17, low(RAMEND) out SPL, r17 ldi r17, high(RAMEND) out SPH, r17

How to make two otherwise identical pointer types incompatible

一曲冷凌霜 提交于 2019-12-05 20:33:00
问题 On certain architectures it may be necessary to have different pointer types for otherwise identical objects. Particularly for a Harvard architecture CPU, you may need something like: uint8_t const ram* data1; uint8_t const rom* data2; Particularly this is how the definition of pointers to ROM / RAM looked like in MPLAB C18 (now discontinued) for PICs. It could define even things like: char const rom* ram* ram strdptr; Which means a pointer in RAM to pointers in RAM pointing to strings in ROM

avr-gcc: variable must be const in order to be put into read-only section by means of ‘__attribute__((progmem))’

给你一囗甜甜゛ 提交于 2019-12-04 21:23:08
I am trying to reproduce this 4-key-keyboard and for that I am trying to compile its source by compiling it with avr-gcc on my Linux box. I managed to solve a couple errors thrown by the compiler by extending the command line with paramaters, but now I am stuck with the errors below. Thing is that quite a few demo projects on V-USB use the same libraries and throw the same errors and I don't want to wrestle through all the code to try and fix them for every project I want to check out. I realize the best way to go is to fix the errors in the source code, but although the errors below can

How to make two otherwise identical pointer types incompatible

余生颓废 提交于 2019-12-04 03:31:42
On certain architectures it may be necessary to have different pointer types for otherwise identical objects. Particularly for a Harvard architecture CPU, you may need something like: uint8_t const ram* data1; uint8_t const rom* data2; Particularly this is how the definition of pointers to ROM / RAM looked like in MPLAB C18 (now discontinued) for PICs. It could define even things like: char const rom* ram* ram strdptr; Which means a pointer in RAM to pointers in RAM pointing to strings in ROM (using ram is not necessary as by default things are in RAM by this compiler, just added all for

Undefined reference to 'operator delete(void*)'

[亡魂溺海] 提交于 2019-12-03 10:46:00
I'm new to C++ programming, but have been working in C and Java for a long time. I'm trying to do an interface-like hierarchy in some serial protocol I'm working on, and keep getting the error: Undefined reference to 'operator delete(void*)' The (simplified) code follows below: PacketWriter.h: class PacketWriter { public: virtual ~PacketWriter() {} virtual uint8_t nextByte() = 0; } StringWriter.h: class StringWriter : public PacketWriter { public: StringWriter(const char* message); virtual uint8_t nextByte(); } The constructor and nextByte functions are implemented in StringWriter.cpp, but