This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Objcopy throws invalid alignment error when redefining symbols in an executable

Tools:

TI ARM CGT 20.2.7 LTS downloaded from www.ti.com/.../20.2.7.LTS

Problem:

When trying to rename symbols in an executable that contains standard library objects, I get the following error:

ti-cgt-arm_20.2.7.LTS/bin/armobjcopy: error: invalid alignment 1 of group section '_ZNSt16initializer_listIiEC1EPKij'

What is causing this error and what can I do resolve this?

Thanks for your help,
Alec

Minimum Recreation Example:

Sandbox.cpp:

#include <initializer_list>

class Foo
{
public:
  std::initializer_list<int> list;
};

extern "C" void foo()
{
  Foo f;
  f.list = {1, 2, 3};
}

int main()
{
  foo();
  return 0;
}

> ti-cgt-arm_20.2.7.LTS/bin/armcl sandbox.cpp -I ti-cgt-arm_20.2.7.LTS/include/ --output_file=sandbox

> ti-cgt-arm_20.2.7.LTS/bin/armobjcopy --redefine-sym=foo=new_foo sandbox

  • This command ...

    > ti-cgt-arm_20.2.7.LTS/bin/armcl sandbox.cpp -I ti-cgt-arm_20.2.7.LTS/include/ --output_file=sandbox

    ... does not build a complete working executable.  It only builds a single object file.  That is why the armobjcopy command fails. It would be ideal if the armobjcopy command recognized that and issued a relevant error diagnostic.  

    You can redefine symbols while linking.  Please search the TI ARM assembly tools manual for the sub-chapter titled Mapping of Symbols.  That is likely to be the best way to resolve the problem.

    Thanks and regards,

    -George

  • Hi George,

    Thanks for the response! Renaming the symbol works when I don't include any C++ objects in the file, even if I'm just building an object file. Additionally, this works when compiling an object file with GCC on Ubuntu 20.04 (my dev environment).

    To provide some background, I am compiling the same 3rd party code base into two different static libraries. I have to rename all the public symbols before linking these libraries to avoid the multiple definition linker error. This all works when I am only using free functions, but the second I introduce objects, I get some form of that error. Any idea what that would be?

    Thanks,
    Alec

  • I misunderstood what you are trying to do.  Thank you for the explanation.  I agree that this ...

    ti-cgt-arm_20.2.7.LTS/bin/armobjcopy: error: invalid alignment 1 of group section '_ZNSt16initializer_listIiEC1EPKij'

    ... should not occur.  I filed EXT_EP-11551 to have this investigated.  You are welcome to follow it with that link.

    Thanks and regards,

    -George