0

Time to time when I try to compile some libraries such as OpenCV or OpenBLAS under linux I encounter error: invalid operands (*UND* and *UND* sections) for '*'. I know this is an assembly error however most of the time when this issue appear it is related to temporary assembly filed generated by the compiler (gcc, g++, gfortran depending on the library). I am not familiar with assembly and have absolutely no idea how to fix it.

Can you help me to have a better understanding on how to fix it ?

Note I am working on a Debian Jessy, but I also encounter this issue in several other Debian based distros (such as Ubuntu, and Mint).

When I write these line I face that error trying to compile OpenCV's librariry. I message send by g++ is: enter image description here

More precisely:

*

/tmp/ccL3rvH2.s: Assembler messages:
/tmp/ccL3rvH2.s:533: Error: invalid operands (*UND* and *UND* sections) for `*'
modules/imgproc/CMakeFiles/opencv_imgproc.dir/build.make:592: recipe for target 'modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/gabor.cpp.o' failed
make[2]: *** [modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/gabor.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
/tmp/cciiML9T.s: Assembler messages:
/tmp/cciiML9T.s:88450: Error: invalid operands (*UND* and *UND* sections) for `*'
/tmp/cciiML9T.s:105860: Error: invalid operands (*UND* and *UND* sections) for `*'
modules/imgproc/CMakeFiles/opencv_imgproc.dir/build.make:760: recipe for target 'modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/imgwarp.cpp.o' failed
make[2]: *** [modules/imgproc/CMakeFiles/opencv_imgproc.dir/src/imgwarp.cpp.o] Error 1
CMakeFiles/Makefile2:2378: recipe for target 'modules/imgproc/CMakeFiles/opencv_imgproc.dir/all' failed
make[1]: *** [modules/imgproc/CMakeFiles/opencv_imgproc.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

*

Thanks in advance for any help

John_Sharp1318
  • 939
  • 8
  • 19
  • 1
    Please show your code and the exact error message. Since Stack Overflow hides the Close reason from you: *Questions seeking debugging help ("why isn't this code working?") must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Questions without a clear problem statement are not useful to other readers. See: [How to create a Minimal, Complete, and Verifiable example](http://stackoverflow.com/help/mcve).* – jww Nov 08 '17 at 15:16
  • You might also find [gcc with parameters “-S -save-temps” puts intermediate files in current directory](https://stackoverflow.com/q/2165079/608639) (and friends) useful. Once you save the temporary file you can copy/paste the offending code from the assembler. – jww Nov 08 '17 at 15:17
  • I assume you tried to do something like `mov $( $A * $B ), %eax` to do math on constants at assemble time. That's the wrong syntax, you want `mov $(A * B), %eax`. – Peter Cordes Nov 08 '17 at 16:39
  • Note that distribution usually doesn't matter when programming in assembly as the toolchain is the same everywhere. – fuz Nov 08 '17 at 16:57
  • Hello everyone thanks you very much for your answers. Actually I am not dealing with assembly directly. I encounter that issue when I try to compile OpenCV (version 3.2.0). The issue when the compiler want to compiler the gabor filter. – John_Sharp1318 Nov 09 '17 at 13:24
  • Could explain me why you marked this question has a duplicates considering the fast I am not working in assembly ? I had this error compiling a library coded in C++ – John_Sharp1318 Nov 10 '17 at 15:29
  • 1
    I just got the same error, *and it has nothing to do with what is marked as dupplicate*. The problem is that your quesiton does not explain your problem. My problem (which *could* be related to yours*) is that I wanted to refer to the size of a code in another assembly module by doing `end-begin`, where begin and end were pointers to a piece of code, known at link-time only. The problem is that the linker can't perform compile-time calculations, only the assembler can... – Bregalad Nov 10 '17 at 19:43
  • ...so I solved this by exporting the size with `.equ size, end-begin` and then `.globl size`. Finally I refered to it in the first assembly module with `.word size`, seems to work great, because this time the assembler can compute size directly, send it to the linker, which solves it in the first assembly reference, no calculation needed. I hope this helps. – Bregalad Nov 10 '17 at 19:44
  • @Bregalad Thank you very much for your answer ans explanation :). Actually in my case I just want to make a local compilation. In my case I am trying to compile a code OpenCV, I know I can play on some parameters such as the depencies, and some usual compiler options, but not directly the assembly. Also my issue seem to happen in a temporary assembly file. – John_Sharp1318 Nov 12 '17 at 05:24
  • I marked it as a duplicate as a guess. You said "(yes it's an assembly issue)", and didn't say this was compiler-generated asm. So of course I assumed you wrote the asm yourself. You didn't show the code causing the error, so I was going to vote-to-close with one reason or another, and duplicate had a chance of actually being useful. If your compiler makes asm that doesn't assemble, that's a compiler bug and you should report it. – Peter Cordes Nov 12 '17 at 05:25
  • @Bregalad: actually the linker *can* do calculations, but only symbol-address +/- constant. I just tried it, and you don't need to store the length in memory, you can still get the difference between two symbols as an immediate. But *only* if the one you're subtracting is part of the current file. e.g. in `foo.S` which defines `foo:`, I can do `add $(bar-foo), %eax`, but not `add $(foo-bar), %eax` (that gives me `Error: can't resolve 'bar' {.text section} - 'foo' {*UND* section}` for the reasons explained in [the Q&A I linked as a dup](https://stackoverflow.com/a/46870205/224132).) – Peter Cordes Nov 12 '17 at 05:40
  • @Bregalad: Notice that in my answer on that other question, I explained that you can't do arbitrary operations on link-time constants, only assemble-time constants. – Peter Cordes Nov 12 '17 at 05:42
  • @Jonny_S: Copy/paste the text from your xterm instead of showing a picture of it. – Peter Cordes Nov 12 '17 at 05:45
  • @PeterCordes another thank you for your help. I added the output of the console and rephrase what my question in order to try to make it clearer. – John_Sharp1318 Nov 12 '17 at 14:01
  • You still didn't show the command that ran to produce those error messages, or the compiler-generated asm that the assembler choked on, or the source that produced that. The error message tells you line `533` of one of the tmp files... More importantly, even if I wanted to go and try to reproduce this on my desktop, you don't even have a link to the library source that you were compiling, or with what compile options. – Peter Cordes Nov 12 '17 at 15:08
  • @PeterCordes The command that generate the error is: make -j -l16 ... that give no information because it is just executing a make file. The librairy source in the case I sited in my post are the legacy code of OpenCV you can find here: https://github.com/opencv/opencv And the option I compile with are the default ones :). The compiler I used was g++ 4.9.2. This error happen while locally compiling a library not trying to devellop anything. – John_Sharp1318 Nov 13 '17 at 14:17
  • @PeterCordes OpenCV's compilation print hundreds of lines between the warning and the prints that inform the user what is happening, it is not easily possible to copy paste the full xterm output from such a project. Even if it was the error would represent less than ten lines in the middle of hundreds. – John_Sharp1318 Nov 13 '17 at 14:25
  • You're asking on Stack Overflow in the `[assembly]` tag. You didn't even tag this with `[opencv]`, so I assumed you wanted to fix the real problem. Anyway, you don't have to post the *whole* output, just the `gcc` command that `make` ran for that file. And use `-save-temps` to get gcc to save the `.s`, so you can extract line 533 for the question. – Peter Cordes Nov 13 '17 at 17:31
  • @peterCordes I really appreciate your help but let me clarify the follow points. My initial post didn't had the assembly tag for one reason. It is not an assembly question. It is a compilation one. The difference is there almost (OpenBlas is an exeption) each time I encounter that error the library have no assembly file related. This error come from a rule the compiler as follow that at the end make that error. My question concern the identification of that rule in order understand it. – John_Sharp1318 Nov 13 '17 at 19:35
  • @peterCordes If you had ever compile a huge library using either cmake, a configuration file or any other way to configure the compilation you should remember there is never one make file but several and there is tons of call to gcc. Can my issue be related to a "bad' (inapropriate) flag ? Yes but unlikely as long as : I didn't set any options exept the default ones I use a project that is support by actively supported a huge and divers community that is the case of many project. – John_Sharp1318 Nov 13 '17 at 19:43
  • So can I know what is the issues by looking the option gcc/g++ command ? Inf act no because most of the options such as -O3, -Ofast ... are highliekly to have a different behavior depending on the properties of the computer that is compiling the code. Can I put a new flag ? Yes but not without a useless pain associate with a huge waste of time. – John_Sharp1318 Nov 13 '17 at 19:45

1 Answers1

0

After updated my compiler I retried to compile the version of OpenCV that I had my error message and it worked perfectly. I change the compiler to go back to the previous version I used (g++ 4.9.2) and the issue re-happen. I am still interested by the reason why this issue happen, but it seem the compiler version had an influence on it.

John_Sharp1318
  • 939
  • 8
  • 19