Hello everyone, @Lin thank you for your feedback. However, I don't want to add a constraint on rewriting switch cases in if/else, I would be happy that the compiler can handle it at its end. For instance, GCC is able to remove jump tables even when there are switch cases in the source code with the option "-fno-jump-tables".
@Keith, the example I took was the simple Go code below, so no cgo involved. I built it with the command *go build -gcflags='-N -l' . . *I analyzed the binary in Ghidra and I saw the switch tables I mentioned (being actually jump tables) in the .rodata section. --> However, I figured out that by using the command *go build -o <bin-name> -compiler=gccgo -gccgoflags='-fno-jump-tables' . *, I successfully get a binary of the same code without jump tables in the .rodata section. The issue with GCCGO is that it doesn't handle Go functionalities about Go1.18 (see https://www.mail-archive.com/debian-bugs-dist@lists.debian.org/msg1983336.html) so it's quite limiting. ---------------------------------------------- *package mainimport "fmt"func main() { x := 10 switch x { case 1: fmt.Println("One") case 5: fmt.Println("Five") case 10: fmt.Println("Ten") default: fmt.Println("Other") }}* ---------------------------------------------- @Ian, I'm working on bug detection, and there seems to be more granularity and therefore more accuracy in analyzing low-level code than source code. Best, Karolina On Friday, November 29, 2024 at 6:39:02 AM UTC+1 Ian Lance Taylor wrote: > On Thu, Nov 28, 2024, 1:13 AM 'Karolina GORNA' via golang-nuts < > golan...@googlegroups.com> wrote: > >> >> @Ian, ok I understand thank you. I am working on Go binary analysis and >> this feature would help a lot. > > > Out of curiosity, why do you want to do binary analysis on a program if > you can ask for specific options to be used when building? Why not just do > source analysis, for which there are a bunch of good tools available? > > Ian > -- Les informations contenues dans ce message électronique ainsi que celles contenues dans les documents attachés sont strictement confidentielles et sont destinées à l'usage exclusif du (des) destinataire(s) nommé(s). Toute divulgation, distribution ou reproduction, même partielle, en est strictement interdite sauf autorisation écrite et expresse de l’émetteur. Si vous recevez ce message par erreur, veuillez le notifier immédiatement à son émetteur par retour, et le détruire ainsi que tous les documents qui y sont attachés. The information contained in this email and in any document enclosed is strictly confidential and is intended solely for the use of the individual or entity to which it is addressed. Partial or total disclosure, distribution or reproduction of its contents is strictly prohibited unless expressly approved in writing by the sender. If you have received this communication in error, please notify us immediately by responding to this email, and then delete the message and its attached files from your system. -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion visit https://groups.google.com/d/msgid/golang-nuts/c75ab53e-915a-4de7-833f-3a8785eab3b8n%40googlegroups.com.