View Single Post
pichlo's Avatar
Posts: 6,450 | Thanked: 20,983 times | Joined on Sep 2012 @ UK
#1
I am fiddling with Qt and, as always, writing and compiling the code on the phone itself. All was hunky-dory for many edit-and-compile iterations until I suddenly out of the blue started receiving this error:
Code:
{standard input}: Assembler messages:
{standard input}:766: Error: bad instruction `orn r3,r3,#127'
make: *** [waveform.o] Error 1
This is the code that triggered all the fuss:
Code:
void WaveForm::on_comboFreqPeriod_currentIndexChanged (int index)
{
  ui.comboFreqPeriodUnit->clear();
  switch (index)
  {
  case FREQUENCY:
    ui.comboFreqPeriodUnit->addItem("Hz");
    ui.comboFreqPeriodUnit->addItem("kHz");
    break;
  case PERIOD:
    ui.comboFreqPeriodUnit->addItem(micro + "s");
    ui.comboFreqPeriodUnit->addItem("ms");
    ui.comboFreqPeriodUnit->addItem("s");
    break;
  default: // impossible but let's keep gcc happy
    break;
  }
  ui.comboFreqPeriodUnit->setCurrentIndex(1);
}
Removing the blue bit makes it behave again. I even suspected some hidden non-ASCII sneaking into the code somewhere, so I deleted the offending lines completely and wrote them again from scratch. Same results.

Now here comes the interesting part. Various vays of editing the code got rid of the error:
  • Add a declaration of something involved at the beginning of the function. It does not need to be used, as long as the con/destructor is being called. An int was not enogh, but e.g. an QStringList did the trick.
  • Split the string literal in one of the blue lines to something like QString("k") + "Hz".
  • Change switch(index) to switch(index+1), with obvious changes to the case labels.
What did not work:
  • Change the string literals.
  • Add an another addItem line with a string literal argument.
  • Remove one of the blue lines (removing both worked though).

All this points me in the direction of code size. In all cases that fixed the problem, a significant amount of additional code was generated or removed. My theory is that the compiler generates the code in multiples of X bytes and adds padding as necessary, and that the orn r3,r3,#127 instruction is somehow involved in that. Adding or removing enough code changes the padding and avoids using the instruction.

Does anyone have a better explanation or, better still, a solution? I am using gcc 4.6.1 from extras-devel, if that makes any difference, and am using the CFLAGS trick suggested here to build Qt on the phone. Perhaps another flag is required?
 

The Following 2 Users Say Thank You to pichlo For This Useful Post: